Skip to content

Commit d1d8b4d

Browse files
authored
Stop pumping frames in applicationWillResignActive (#7450)
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
1 parent abbc34e commit d1d8b4d

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎shell/platform/darwin/ios/framework/Source/FlutterViewController.mm‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,24 +436,24 @@ - (void)dealloc {
436436

437437
- (void)applicationBecameActive:(NSNotification*)notification {
438438
TRACE_EVENT0("flutter", "applicationBecameActive");
439+
if (_viewportMetrics.physical_width)
440+
[self surfaceUpdated:YES];
439441
[[_engine.get() lifecycleChannel] sendMessage:@"AppLifecycleState.resumed"];
440442
}
441443

442444
- (void)applicationWillResignActive:(NSNotification*)notification {
443445
TRACE_EVENT0("flutter", "applicationWillResignActive");
446+
[self surfaceUpdated:NO];
444447
[[_engine.get() lifecycleChannel] sendMessage:@"AppLifecycleState.inactive"];
445448
}
446449

447450
- (void)applicationDidEnterBackground:(NSNotification*)notification {
448451
TRACE_EVENT0("flutter", "applicationDidEnterBackground");
449-
[self surfaceUpdated:NO];
450452
[[_engine.get() lifecycleChannel] sendMessage:@"AppLifecycleState.paused"];
451453
}
452454

453455
- (void)applicationWillEnterForeground:(NSNotification*)notification {
454456
TRACE_EVENT0("flutter", "applicationWillEnterForeground");
455-
if (_viewportMetrics.physical_width)
456-
[self surfaceUpdated:YES];
457457
[[_engine.get() lifecycleChannel] sendMessage:@"AppLifecycleState.inactive"];
458458
}
459459

0 commit comments

Comments
 (0)