loadData method
Implementation
Future<void> loadData() async {
if (_rawJson != null) return;
String phonemeData = '{}';
try {
try {
phonemeData = await rootBundle.loadString(
'packages/recite_quran/assets/model/ordered_quran_phonemes.json',
);
} catch (_) {
phonemeData = await rootBundle.loadString(
'assets/model/ordered_quran_phonemes.json',
);
}
} catch (e, stack) {
// Re-throw so the Orchestrator can show an error instead of silently breaking the matching system
print('CRITICAL ERROR loading quran phonemes: $e\n$stack');
rethrow;
}
// Decode synchronously on the main isolate.
// Spawning a 3rd concurrent isolate here (alongside the Sherpa isolate and the
// alignment isolate) pushes RSS to ~300MB+ during startup on 32-bit low-RAM
// devices (e.g. Redmi 2020), triggering the OOM killer.
// jsonDecode of the ~15MB Quran JSON takes < 200ms — acceptable for a one-time load.
_rawJson = jsonDecode(phonemeData) as Map<String, dynamic>;
}