From d1d8b4d41611f31433f054d752aceb387d25cf02 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Sat, 12 Jan 2019 09:14:23 -0800 Subject: [PATCH] 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 --- .../darwin/ios/framework/Source/FlutterViewController.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm index 5a367bdeae6..4d066b21f9c 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm @@ -436,24 +436,24 @@ - (void)applicationBecameActive:(NSNotification*)notification { TRACE_EVENT0("flutter", "applicationBecameActive"); + if (_viewportMetrics.physical_width) + [self surfaceUpdated:YES]; [[_engine.get() lifecycleChannel] sendMessage:@"AppLifecycleState.resumed"]; } - (void)applicationWillResignActive:(NSNotification*)notification { TRACE_EVENT0("flutter", "applicationWillResignActive"); + [self surfaceUpdated:NO]; [[_engine.get() lifecycleChannel] sendMessage:@"AppLifecycleState.inactive"]; } - (void)applicationDidEnterBackground:(NSNotification*)notification { TRACE_EVENT0("flutter", "applicationDidEnterBackground"); - [self surfaceUpdated:NO]; [[_engine.get() lifecycleChannel] sendMessage:@"AppLifecycleState.paused"]; } - (void)applicationWillEnterForeground:(NSNotification*)notification { TRACE_EVENT0("flutter", "applicationWillEnterForeground"); - if (_viewportMetrics.physical_width) - [self surfaceUpdated:YES]; [[_engine.get() lifecycleChannel] sendMessage:@"AppLifecycleState.inactive"]; }