We are currently facing an issue with Flutter module embedding, specifically in iOS. We are embedding a flutter module into an existing native iOS application application using plugin frameworks in Xcode and Flutter framework with CocoaPods. We are using FlutterAppDelegate by creating a FlutterAppDelegate subclass of AppDelegate and initializing the FlutterEngine. Then we initialize a FlutterViewController using this engine and push it into the navigation controller. Everything is working fine with no issues observed.
The problem
When app stays in the background for a long period of time and then is brought back to the foreground, the flutter view is not visible and only a white screen is displayed. This white screen displays instantly and never restores. The only way to resolve it would be to manually kill the app by dismissing it from the App Switcher. Good to mention; we tested this many times with test builds and only face the issue sparingly. Also, we haven’t been able to reproduce it in the simulator
What we are tried
- We tried to refresh the Flutter view from inside the Flutter code by using a Flutter channel once app comes to the foreground, but this did not prove to be a solution.
- We tried to remove the FlutterViewController, remove the Flutter engine and then reinitialize both, just like it is done in a regular app launch, but this did not work either.
We are reaching out to see if anyone can provide us with some lights on how to tackle this issue. The iOS native app is developed in Objective-C and runs in iOS 13+ devices, we are using Xcode 14.2, Flutter 3.3.10 and Dart 2.18.6