flutter-unity-view-widget
flutter-unity-view-widget copied to clipboard
Android freeze at launch when the app has been "killed" while in background
Describe the bug When I put the app in background, after some time when it get "killed" by Android it is not possible to open the app anymore because it freeze.
To Reproduce Steps to reproduce the behavior:
- Clone the branch master of https://github.com/juicycleff/flutter-unity-view-widget
- Follow the instructions of the README.md to export the folder unityLibrary of the DemoApp. I used the Unity Editor version 2021.3.25f1 (Set in Unity Hub and local.properties) and file fuw-2022.2.0.unitypackage.
- Go in the Developper Settings of the devive and enable "Don't keep activities" to force Android to kill the app as soon as it get in background. Otherwise we would have to wait a random amount of time to trigger the kill. (cf: first screenshot)
- Launch the app, go to "Simple Unity Demo"
- Simply put the app in background. You will get "Lost connection to device." in the log.
- Try to open the app again and it will freeze (cf: second screenshot).
Expected behavior I would like the be able to launch the app again and see the Menu List at least. Actually I have to kill the app manually and open it again after the freeze.
Screenshots
Unity (please complete the following information):
- OS: Windows 11
- Version Editor Version 2021.3.25f1
Smartphone (please complete the following information):
- Device: Redmi Note 9S (cf: third screenshot)
- OS: Android
- Version: Android 11
Additional context I have the same issue when I replace the DemoAPP by my own Unity app. And when I build an apk from Unity directly (of my own app), there is no freeze with the same steps.
Thanks for the detailed instructions.
I followed your exact steps with this setup:
- Unity 2021.3.21
- Flutter 3.7.12
- Plugin 2022.2.0
- unitypackage fuw-2022.2.0
- Samsung Galaxy S20FE, Android 13.
I can replicate the issue when launching the app from Flutter in Visual studio code. However once the app has been killed once (and your freeze shows up), the issue does not show up on any further launches of the app.
I also can't replicate the issue when installing the example from an apk file.
It might have something to do with the Flutter debugger.
Thanks for the fast reply. I confirm that I have also no problem when i test from an apk of the example. I tested with an apk from Unity only before, so my issue is kind of fixed now. It certainly has to do with the Flutter debugger and I guess there isn't much to do on the library to fix this.