Android hot reload cause crash
See original GitHub issueThe TrackPlayerPlugin and the FlautoPlayerPlugin share a common slot array.
If you do a hot reload the array is not cleared out. The result is that when you restart the slots are not reset and you can get a class cast exception (as a given slot could contain a Track or a Fluato) plugin.
Whilst this is not a problem for running code it will cause problems and confusing during development. We have a couple of options.
- separate the slot arrays so each plugin has its own.
- clean up the slot arrays when a hot reload occurs.
- I have some code in Playbar that can detect a hot reload however there is no code in the plugins to free slots (the freeSlot method exists but is never called). I thought that onDetachedFromEngine from engine in Flauto.java might be the place to do this but I have no experience with plugins.
To reproduce this problem: Play Asset with OS Media Player off hot reload Play Asset with OS Media Player on.
This problem can be reproduced on the dev branch code however I believe that it will be a problem in the current production release.
I/flutter (23913): Loading starting
I/flutter (23913): Calling startPlayer
I/flutter (23913): regisetered Proxy: 1065489832
I/flutter (23913): initialise called Proxy: 1065489832
I/flutter (23913): #################SpinKit rendered###################
E/MethodChannel#com.dooboolab.flutter_sound_track_player(23913): Failed to handle method call
E/MethodChannel#com.dooboolab.flutter_sound_track_player(23913): java.lang.ClassCastException: com.dooboolab.fluttersound.FlutterSoundPlayer cannot be cast to com.dooboolab.fluttersound.TrackPlayer
E/MethodChannel#com.dooboolab.flutter_sound_track_player(23913): at com.dooboolab.fluttersound.TrackPlayerPlugin.onMethodCall(TrackPlayer.java:132)
E/MethodChannel#com.dooboolab.flutter_sound_track_player(23913): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:231)
E/MethodChannel#com.dooboolab.flutter_sound_track_player(23913): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:93)
E/MethodChannel#com.dooboolab.flutter_sound_track_player(23913): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:642)
E/MethodChannel#com.dooboolab.flutter_sound_track_player(23913): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#com.dooboolab.flutter_sound_track_player(23913): at android.os.MessageQueue.next(MessageQueue.java:336)
E/MethodChannel#com.dooboolab.flutter_sound_track_player(23913): at android.os.Looper.loop(Looper.java:174)
E/MethodChannel#com.dooboolab.flutter_sound_track_player(23913): at android.app.ActivityThread.main(ActivityThread.java:7356)
E/MethodChannel#com.dooboolab.flutter_sound_track_player(23913): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#com.dooboolab.flutter_sound_track_player(23913): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/MethodChannel#com.dooboolab.flutter_sound_track_player(23913): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Crash while hot-reloading · Issue #40361 · flutter/flutter - GitHub
This is the console output in Android Studio just after the crash. Initializing hot reload... Syncing files to device Pixel 2 XL.
Read more >Flutter app crashes on hot restart only on iOS Simulator
After two days of debugging I have just found out it was caused by one of my dependencies. It is firebase_auth package version...
Read more >MAUI Android App crashes with Hot Reload enabled on ...
When running on Android Emulator (Pixel 2 R.11.0 - API 30 - x86), if Hot Reload is enabled, the app starts, show the...
Read more >Manually reloading your Flutter web app causes it to crash/get ...
It either crashes or never finish reloading.
Read more >Crashes - Android Developers
An Android app crashes whenever there's an unexpected exit caused by an unhandled exception or signal. An app that is written using Java...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think there is perhaps an argument for a single plugin which then routes calls to the appropriate class.
At the very least I think we should combine the trackplayer and soundplayer into a single plug. I can’t see any obvious reason why these are separate (unless there is some aspect I’ve missed). Tracker already extends soundplayer. A singular class would make the plugin easier to work with.
On Sun, 19 Apr 2020 at 19:58, Larpoux notifications@github.com wrote:
Fixed in Flutter Sound release 7.6.3