fix(05-jamtrack): require sample rate match and fix error boundary
Two critical fixes:
1. Error Boundary Crash
- errorInfo can be null between getDerivedStateFromError and componentDidCatch
- Added null check: {this.state.errorInfo && this.state.errorInfo.componentStack}
- Prevents "Cannot read properties of null" error
2. Sample Rate Mismatch
- Removed fallback to different sample rates (tier 4)
- Native client CANNOT play packages with mismatched sample rates
- If client is 44kHz but package is 48kHz, play will fail with "Unable to play JamTrack"
- Now throws clear error: "No package available for sample rate 44kHz. Available rates: 48kHz"
Root cause of play failure:
- Client sample rate: 44kHz (from GetSampleRate 44.099998...)
- Package downloaded: 48kHz (only available package)
- fqId built: jamTrack.id-44 (based on client rate)
- Native client cannot play 48kHz files with 44kHz fqId → Play fails
Solution:
- Sample rate fallback removed - must match exactly
- User gets actionable error message suggesting to restart audio interface
or select different sample rate
Fixes "Unable to play JamTrack" error and error boundary crash.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
b78fae11e3
commit
d9139ebcbd
|
|
@ -33,7 +33,7 @@ class ErrorBoundary extends React.Component {
|
|||
<pre className="mt-2 text-white">
|
||||
{this.state.error && this.state.error.toString()}
|
||||
<br />
|
||||
{this.state.errorInfo.componentStack}
|
||||
{this.state.errorInfo && this.state.errorInfo.componentStack}
|
||||
</pre>
|
||||
</details>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -88,11 +88,11 @@ export const downloadJamTrack = createAsyncThunk(
|
|||
}
|
||||
|
||||
// pickMyPackage logic with fallback strategy
|
||||
// Preference order:
|
||||
// 1. ogg + jkz encryption + matching sample rate (ideal)
|
||||
// 2. ogg + any encryption + matching sample rate
|
||||
// 3. any format + matching sample rate
|
||||
// 4. any package (last resort)
|
||||
// CRITICAL: Sample rate MUST match - native client cannot play mismatched rates
|
||||
// Preference order for matching sample rate:
|
||||
// 1. ogg + jkz encryption (ideal for security)
|
||||
// 2. ogg + any/no encryption (preferred format)
|
||||
// 3. any format (mp3, etc.)
|
||||
|
||||
let compatiblePackage = null;
|
||||
|
||||
|
|
@ -118,14 +118,10 @@ export const downloadJamTrack = createAsyncThunk(
|
|||
);
|
||||
}
|
||||
|
||||
// Try 4: Just use first available package
|
||||
// No fallback to different sample rates - client cannot play mismatched rates
|
||||
if (!compatiblePackage) {
|
||||
compatiblePackage = mixdown.packages[0];
|
||||
console.warn(`[JamTrack] No package matches sample rate ${sampleRate}kHz, using first available package (${compatiblePackage.file_type}, ${compatiblePackage.sample_rate}kHz)`);
|
||||
}
|
||||
|
||||
if (!compatiblePackage) {
|
||||
throw new Error(`No packages available for mixdown "${mixdown.name}"`);
|
||||
const availableRates = mixdown.packages.map(p => p.sample_rate).join(', ');
|
||||
throw new Error(`No package available for sample rate ${sampleRate}kHz. Available rates: ${availableRates}kHz. Try restarting your audio interface or selecting a different sample rate.`);
|
||||
}
|
||||
|
||||
const packageId = compatiblePackage.id;
|
||||
|
|
|
|||
Loading…
Reference in New Issue