Flutter app UI is frozen after reactivated from background on IOS

1,257

Solution 1

After updating Flutter to 1.20.3, this bug is fixed!

Solution 2

Make sure that the state of your app is cached some way after entering background. It might not be in memory any more after a longer period of time and your UI is unable to render without it.

The issue does not seem to be related to background location fetching - try isolating that problem by running your app on a real device with debug enabled. Switch it to background and open some memory hungry apps to force your app's termination. After that open the app and check the logs, there should be some kind of indication what caused the Flutter UI freeze.

Solution 3

Last time I faced this issue on both ios and android it was actually related to my state manager which was provider package. I finally managed it by saving data in sqlite when app goes to background and flushing provider itself and re initiate state each time that app opens from task manager.

Share:
1,257
Tom
Author by

Tom

Updated on November 24, 2022

Comments

  • Tom
    Tom over 1 year

    I have an application developed in Flutter, and I have some problem with it on IOS when activating from background.

    It is enabled to use location background mode on IOS. It works in background without any problem, even for days, it does what it has to do. But when I open the app after a longer time period (about one day or more) working in background, the UI is frozen! Note, if I do it after some hours, it is okkey, the problem comes after a longer period.

    Flutter version: [✓] Flutter (Channel stable, 1.20.1, on Mac OS X 10.15.5 19F101, locale hu-HU)

    What can I do to fix it? Should I re-init UI somehow in Flutter? Or do anything from native side?

    Thanks a lot, any help is highly appriciated!

  • Tom
    Tom over 3 years
    It is related with background location fetching. If I comment it out, the app does not freeze after opening it. Thanks a lot for your supoort!
  • mgapinski
    mgapinski over 3 years
    If it's the case you'll need to give implementation details, eg. what plugin did you use in flutter, check if all background modes are enabled in Xcode etc. Given recent changes in location apis on iOS I would recommend checking if the plugin does not use any deprecated stuff
  • mgapinski
    mgapinski over 3 years
    Try to capture logs in the way I told you without removing the location stuff -> there has to be something there
  • mgapinski
    mgapinski over 3 years
    this does not directly apply to Flutter apps