Repository navigation
Description
Use case
To keep it short, applications built with flutter do not continue to render whilst out of view or in IOS's app switcher.
This is a bad behaviour from mobile apps imo . Might be a limitation from the framework, not sure.
It also causes an unpleasant UI/UX when scrolling through a ListView and the the application is removed from view. When
the application is brought back into view it jumps suddenly depending on the scroll extent.
Here is a gif description comparing Instagram and a mock flutter application.
Proposal
According to #5449 and #11421 , this was fixed. Although this was as far back 2017/2018 and Flutter has had many updates since then. Maybe a revision of what was changed could be implemented once more.
Environment
A minimal code snippet that would reproduce this issue.
import 'package:flutter/material.dart';
void main() {
runApp(App());
}
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Issue(),
);
}
}
class Issue extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Issue'),
),
body: ListView.builder(
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.all(16.0),
child: Text('Issue test'),
);
},
itemCount: 350,
),
);
}
}
flutter doctor -v
[✓] Flutter (Channel stable, 1.22.0, on Mac OS X 10.15.7 19H15, locale en-GB)
• Flutter version 1.22.0 at /Users/adeola/Downloads/flutter
• Framework revision d408d302e2 (8 weeks ago), 2020-09-29 11:49:17 -0700
• Engine revision 5babba6c4d
• Dart version 2.10.0
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at /Users/adeola/Library/Android/sdk
• Platform android-30, build-tools 30.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.0.1, Build version 12A7300
• CocoaPods version 1.10.0.rc.1
[!] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
[✓] VS Code (version 1.51.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.16.0
[✓] Connected device (1 available)
• iPhone (mobile) • 7301a50cae9aaf2e903ef313e632bfed64bb3704 • ios • iOS 14.0

Activity
pedromassangocode commentedon Nov 23, 2020
Hi @adeolaex
What you want to achieve is called State Restoration, there is not issue here. Even on native Android/iOS app the system may stop your app's process to release resources for the app in foreground, See https://developer.apple.com/documentation/uikit/view_controllers/preserving_your_app_s_ui_across_launches.
Flutter has recently introduce this however there is no support for iOS currently #62915. See for more info #62916.
The announcement was made in https://medium.com/flutter/announcing-flutter-1-22-44f146009e5f.
AdeolaKOD commentedon Nov 23, 2020
HEY @pedromassangocode
This issue has nothing to deal with State Restoration. If the text explaining the issue wasn't clear enough, at least look at the Gif provided.
Both the native app ( Instagram ) and the Flutter app never make it to the background. They are both either in foreground or in the app switcher.
What I am describing has to deal with the Flutter app not rendering whilst in the app switcher. On the native app, it continues to scroll whilst in the app switcher. Please look at #5449 !
AdeolaKOD commentedon Nov 23, 2020
In fact, to put it into perspective, we don't even have to go as far as the app switcher. Simply scrolling a list, then immediately dragging up the Control Centre will have the same results.
pedromassangocode commentedon Nov 23, 2020
Thanks for making this clear, I was able to reproduce this on master channel.
Seems to be a regression since this was confirmed to be fixed #5449 (comment).
Cc @xster @Hixie
flutter doctor -v
AdeolaKOD commentedon Nov 23, 2020
@pedromassangocode Thank you very much !
I'm glad you reopened the issue.
AdeolaKOD commentedon Nov 25, 2020
Hey @pedromassangocode , any update on this ?
pedromassangocode commentedon Nov 26, 2020
Hi @adeolaex
No, you will receive notifications once this get closed!
5 remaining items
AdeolaKOD commentedon Dec 13, 2020
pedromassangocode commentedon Dec 15, 2020
zanderso commentedon Mar 10, 2021
/cc @xster Do you know if this is an issue in the iOS embedder or the engine?
xster commentedon Mar 22, 2021
Since we had the rendering while in the app switcher behavior in #11421, we've made a number of tweaks in this area. Mainly to reduce the likelihood of issuing OpenGL commands while the app isn't in the foreground since it's prohibited in iOS and lead to crashes. But we may have not correctly preserved any special casing needed to support the app switcher.
@gaaclarke may know more from looking at it more recently. It's also possible that OpenGL/Metal based apps conceptually need to be narrower in the supported lifecycle span than UiKit apps. Would be good to test via apps like games or Google Earth.
gaaclarke commentedon Mar 23, 2021
Yep, it is possible the disabling of the GPU is too conservative. Here is a PR that is purporting this very thing and addressing it: flutter-team-archive/engine#17396
Edit: I tried out that PR and it
didn'tDID address the issue.Kavantix commentedon Mar 23, 2021
The PR is quite old by now, probably there are now other places in the engine that disable the rendering in the inactive state.
When I made the PR these changes were enough to get it rendering in the app switcher
Edit: turns out the PR worked after correctly merging, the current PR is now: flutter-team-archive/engine#25196
gaaclarke commentedon Mar 29, 2021
Fixed in flutter-team-archive/engine#25196
github-actions commentedon Aug 3, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.