Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Stop pumping frames in applicationWillResignActive - #7450

Merged
cbracken merged 1 commit into
flutter-team-archive:masterfrom
cbracken:pause-frames-earlier
Jan 12, 2019
Merged

cbracken merged 1 commit into
flutter-team-archive:masterfrom
cbracken:pause-frames-earlier

Conversation

@cbracken

@cbracken cbracken commented Jan 12, 2019 •

Copy link
Copy Markdown
Contributor

According to Apple's OpenGL ES Programming guide, applications
should pause any animations in applicationWillResignActive. Any GL calls
after applicationDidEnterBackground will cause the app to be terminated
immedidately by iOS.

The surfaceUpdated:YES call is moved to the handler for the
applicationDidBecomeActive notification to handle cases where the
application becomes inactive then active again without being
backgrounded (e.g. home button double-tap then return to app directly).

According to Apple's OpenGL ES Programming guide [1], applications
should pause any animations in applicationWillResignActive. Any GL calls
after applicationDidEnterBackground will cause the app to be terminated
immedidately by iOS.

The surfaceUpdated:YES call is moved to the handler for the
applicationDidBecomeActive notification to handle cases where the
application becomes inactive then active again without being
backgrounded (e.g. home button double-tap then return to app directly).

[1] https://developer.apple.com/library/archive/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/ImplementingaMultitasking-awareOpenGLESApplication/ImplementingaMultitasking-awareOpenGLESApplication.html#//apple_ref/doc/uid/TP40008793-CH5-SW1
@cbracken

cbracken commented Jan 12, 2019 •

Copy link
Copy Markdown
Contributor Author

Attempt at fixing flutter/flutter#14178, though I haven't been able to repro locally.


- (void)applicationDidEnterBackground:(NSNotification*)notification {
TRACE_EVENT0("flutter", "applicationDidEnterBackground");
[self surfaceUpdated:NO];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, I was sure we did some tweaks in the past to make sure it's not this late.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We did changes on the framework side, but that's async.


- (void)applicationWillEnterForeground:(NSNotification*)notification {
TRACE_EVENT0("flutter", "applicationWillEnterForeground");
if (_viewportMetrics.physical_width)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may cause some jank when coming back.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind. The bug I was thinking of was on the VC level, not application level

@xster

xster commented Jan 12, 2019

Copy link
Copy Markdown
Contributor

I don't have a strong opinion on the way back.

In your app’s applicationWillEnterForeground: method, re-create any objects and restart your animation timer

The doc doesn't sound so strict on the way back. If you tested it and it doesn't look janky, LGTM.

@cbracken

Copy link
Copy Markdown
Contributor Author

Thanks. applicationWillEnterForeground: won't work (see the second paragraph in the commit message for an example case where you'll get the willResignActive notification but never exit foreground (and therefore never get the willEnterForeground notification on return to the app.

@cbracken
cbracken merged commit d1d8b4d into flutter-team-archive:master Jan 12, 2019
@cbracken
cbracken deleted the pause-frames-earlier branch January 12, 2019 17:14
engine-flutter-autoroll added a commit to flutter/flutter that referenced this pull request Jan 14, 2019
flutter-team-archive/engine@abbc34e...17a90fb

git log abbc34e..17a90fb --no-merges --oneline
17a90fb Roll src/third_party/skia 3395f00ef6ee..60a2f675ddce (1 commits) (flutter-team-archive/engine#7458)
3ee3035 Roll src/third_party/skia 160422338c10..3395f00ef6ee (1 commits) (flutter-team-archive/engine#7457)
426e342 Roll src/third_party/skia 9a97c96c9c3a..160422338c10 (1 commits) (flutter-team-archive/engine#7456)
2aa95d3 Roll src/third_party/skia 2ee498c6749a..9a97c96c9c3a (1 commits) (flutter-team-archive/engine#7455)
d1d8b4d Stop pumping frames in applicationWillResignActive (flutter-team-archive/engine#7450)

The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+/master/autoroll/README.md

If the roll is causing failures, please contact the current sheriff ([email protected]), and stop
the roller if necessary.
kangwang1988 pushed a commit to XianyuTech/flutter that referenced this pull request Feb 12, 2019
flutter-team-archive/engine@abbc34e...17a90fb

git log abbc34e..17a90fb --no-merges --oneline
17a90fb Roll src/third_party/skia 3395f00ef6ee..60a2f675ddce (1 commits) (flutter-team-archive/engine#7458)
3ee3035 Roll src/third_party/skia 160422338c10..3395f00ef6ee (1 commits) (flutter-team-archive/engine#7457)
426e342 Roll src/third_party/skia 9a97c96c9c3a..160422338c10 (1 commits) (flutter-team-archive/engine#7456)
2aa95d3 Roll src/third_party/skia 2ee498c6749a..9a97c96c9c3a (1 commits) (flutter-team-archive/engine#7455)
d1d8b4d Stop pumping frames in applicationWillResignActive (flutter-team-archive/engine#7450)

The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+/master/autoroll/README.md

If the roll is causing failures, please contact the current sheriff ([email protected]), and stop
the roller if necessary.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Development

Successfully merging this pull request may close these issues.

3 participants