flutter-unity-view-widget icon indicating copy to clipboard operation
flutter-unity-view-widget copied to clipboard

Android freeze at launch when the app has been "killed" while in background

Open jeromecaudoux opened this issue 1 year ago • 2 comments

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:

  1. Clone the branch master of https://github.com/juicycleff/flutter-unity-view-widget
  2. 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.
  3. 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)
  4. Launch the app, go to "Simple Unity Demo"
  5. Simply put the app in background. You will get "Lost connection to device." in the log.
  6. 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 Screenshot_2023-05-24-11-02-12-619_com android settings Screenshot_2023-05-24-10-50-15-315_com xraph plugin flutter_unity_widget_example Screenshot_2023-05-24-11-01-53-428_com android settings

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.

jeromecaudoux avatar May 24 '23 09:05 jeromecaudoux

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.

timbotimbo avatar May 24 '23 09:05 timbotimbo

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.

jeromecaudoux avatar May 25 '23 08:05 jeromecaudoux