mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-07-26 05:51:18 +02:00
f808a6a369
MainActivity only overrode provideFlutterEngine, so the activity's fragment delegate treated the plugin-cached engine as its own (createFlutterFragment forwards shouldDestroyEngineWithHost, default true) and destroyed it when the activity finished, while the engine stayed registered in AudioServicePlugin's FlutterEngineCache. When AudioService stopped afterwards, disposeFlutterEngine() called destroy() on the already destroyed engine and crashed the app with "Cannot execute operation because FlutterJNI is not attached to native". Mirror audio_service's own AudioServiceFragmentActivity: expose the plugin engine as a cached engine (getCachedEngineId), never destroy it with the host (shouldDestroyEngineWithHost = false), and pre-create it in onCreate. The plugin remains the engine's sole owner and disposes it only once, when the service stops with no activity attached.