[flutter_releases] Flutter stable 2.8.1 Engine Cherrypicks (#30355)
* 'Update Dart SDK to 1278bd5adb6a857580f137e47bc521976222f7b9'
* Update cirrus secret.
* [iOS] Destroy the engine prior to application termination. (#29295)
* Update licenses hash.
* Update shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm
Co-authored-by: Jenn Magder <magder@google.com>
Co-authored-by: Wu Zhong <zhongwuzw@qq.com>
Co-authored-by: Jenn Magder <magder@google.com>
diff --git a/.cirrus.yml b/.cirrus.yml
index a4fc4a3..78043f0 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -1,4 +1,4 @@
-gcp_credentials: ENCRYPTED[!48cff44dd32e9cc412d4d381c7fe68d373ca04cf2639f8192d21cb1a9ab5e21129651423a1cf88f3fd7fe2125c1cabd9!]
+gcp_credentials: ENCRYPTED[!cc769765170bebc37e0556e2da5915ca64ee37f4ec8c966ec147e2f59578b476c99e457eafce4e2f8b1a4e305f7096b8!]
# LINUX
task:
diff --git a/DEPS b/DEPS
index 9e86ff6..8774d68 100644
--- a/DEPS
+++ b/DEPS
@@ -39,7 +39,7 @@
# Dart is: https://github.com/dart-lang/sdk/blob/main/DEPS.
# You can use //tools/dart/create_updated_flutter_deps.py to produce
# updated revision list of existing dependencies.
- 'dart_revision': '3d2629cd0310df74bdf260d828ed3c75f25db889',
+ 'dart_revision': '1278bd5adb6a857580f137e47bc521976222f7b9',
# WARNING: DO NOT EDIT MANUALLY
# The lines between blank lines above and below are generated by a script. See create_updated_flutter_deps.py
diff --git a/ci/licenses_golden/licenses_third_party b/ci/licenses_golden/licenses_third_party
index 7680438..8c0f7e7 100644
--- a/ci/licenses_golden/licenses_third_party
+++ b/ci/licenses_golden/licenses_third_party
@@ -1,4 +1,4 @@
-Signature: fbed5705076e0a8ed5942eaed257e0bc
+Signature: a92ff326020b0e5d29148bd8e830fb6c
UNUSED LICENSES:
diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm
index 59dbefc..1e44a6d 100644
--- a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm
+++ b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm
@@ -277,6 +277,11 @@
object:nil];
[center addObserver:self
+ selector:@selector(applicationWillTerminate:)
+ name:UIApplicationWillTerminateNotification
+ object:nil];
+
+ [center addObserver:self
selector:@selector(applicationDidEnterBackground:)
name:UIApplicationDidEnterBackgroundNotification
object:nil];
@@ -790,6 +795,11 @@
[self goToApplicationLifecycle:@"AppLifecycleState.inactive"];
}
+- (void)applicationWillTerminate:(NSNotification*)notification {
+ [self goToApplicationLifecycle:@"AppLifecycleState.detached"];
+ [self.engine destroyContext];
+}
+
- (void)applicationDidEnterBackground:(NSNotification*)notification {
TRACE_EVENT0("flutter", "applicationDidEnterBackground");
[self surfaceUpdated:NO];
diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm
index a06d19b..82ab3ff 100644
--- a/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm
+++ b/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm
@@ -124,6 +124,8 @@
- (void)scrollEvent:(UIPanGestureRecognizer*)recognizer;
- (void)updateViewportMetrics;
- (void)onUserSettingsChanged:(NSNotification*)notification;
+- (void)applicationWillTerminate:(NSNotification*)notification;
+- (void)goToApplicationLifecycle:(nonnull NSString*)state;
@end
@interface FlutterViewControllerTest : XCTestCase
@@ -167,6 +169,20 @@
OCMReject([viewControllerMock surfaceUpdated:[OCMArg any]]);
}
+- (void)testAppWillTerminateViewDidDestroyTheEngine {
+ FlutterEngine* mockEngine = OCMPartialMock([[FlutterEngine alloc] init]);
+ [mockEngine createShell:@"" libraryURI:@"" initialRoute:nil];
+ FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:mockEngine
+ nibName:nil
+ bundle:nil];
+ id viewControllerMock = OCMPartialMock(viewController);
+ OCMStub([viewControllerMock goToApplicationLifecycle:@"AppLifecycleState.detached"]);
+ OCMStub([mockEngine destroyContext]);
+ [viewController applicationWillTerminate:nil];
+ OCMVerify([viewControllerMock goToApplicationLifecycle:@"AppLifecycleState.detached"]);
+ OCMVerify([mockEngine destroyContext]);
+}
+
- (void)testViewDidDisappearDoesPauseEngineWhenIsTheViewController {
id lifecycleChannel = OCMClassMock([FlutterBasicMessageChannel class]);
FlutterEnginePartialMock* mockEngine = [[FlutterEnginePartialMock alloc] init];