This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Reland "iOS: Migrate FlutterEngine to ARC" #55937
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This reverts commit 2484ae1. This relands commit 449df25. Migrates `FlutterEngine` from manual reference counting to ARC. Migrates properties from `retain` to strong and `assign` to `weak` (where referencing an Obj-C object). Includes two additional fixes on top of the original: * In `waitForFirstFrame:callback:` we ensure FlutterEngine isn't released on a background thread, but instead is always freed on the platform thread. * In `testViewControllerIsReleased` we call loadView prior to calling `viewDidLoad`. `viewDidLoad` calls `[FlutterEngine attachView]` which calls `[PlatformViewIOS::attachView]` which asserts that the view is loaded. No semantic changes, therefore no changes to tests. Issue: flutter/flutter#137801
`[FlutterViewController viewDidLoad]` calls `[FlutterEngine attachView]` which calls `PlatformViewIOS::attachView` which asserts that the view is loaded.
Member
Author
|
First commit is the original patch, unmodified. |
hellohuanlin
approved these changes
Oct 17, 2024
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/flutter
that referenced
this pull request
Oct 18, 2024
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/flutter
that referenced
this pull request
Oct 18, 2024
auto-submit bot
pushed a commit
to flutter/flutter
that referenced
this pull request
Oct 18, 2024
…157143) flutter/engine@09598f6...0bb6b1f 2024-10-18 [email protected] Move redispatch_event from FlKeyboardViewDelegate to FlKeyboardManager (flutter/engine#55941) 2024-10-18 [email protected] Remove FlKeyResponder and use the two responder classes directly. (flutter/engine#55925) 2024-10-17 [email protected] Reland "iOS: Migrate FlutterEngine to ARC" (flutter/engine#55937) 2024-10-17 [email protected] [Flutter GPU] Remove Command/VertexBuffer usage from Flutter GPU. (flutter/engine#55893) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
jonahwilliams
pushed a commit
that referenced
this pull request
Oct 18, 2024
There are still a couple closures where on engine shutdown, the last live reference to FlutterEngine may be on a thread other than the platform thread. Specifically, the profiling data capture callback can result in the last live reference to a FlutterEngine being on a profiling thread, resulting in an assertion failure in the destructor of the PlatformViewsController held by FlutterEngine, because PlatformViewsController holds a WeakPtrFactory whose destructor asserts that it be on the platform thread. See: https://github.com/flutter/engine/blob/ad9e4fef451a73427285826455db5fbdde502bd7/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm#L511-L515 Backtrace of such a crash: ``` ================================================================= Main Thread Checker: UI API called on a background thread: -[UIView removeFromSuperview] PID: 46919, TID: 333147, Thread name: FlutterEngine.166.profiler, Queue name: com.apple.root.default-qos.overcommit, QoS: 0 Backtrace: 4 libios_test_flutter.dylib 0x000000014b658aed -[FlutterTextInputPlugin dealloc] + 27 5 libobjc.A.dylib 0x00007ff800055228 _ZN11objc_object17sidetable_releaseEbb + 204 6 libios_test_flutter.dylib 0x000000014b63df5a -[FlutterEngine .cxx_destruct] + 135 7 libobjc.A.dylib 0x00007ff800035766 _ZL27object_cxxDestructFromClassP11objc_objectP10objc_class + 83 8 libobjc.A.dylib 0x00007ff80004ddfc objc_destructInstance + 61 9 CoreFoundation 0x00007ff8004a286b -[NSObject(NSObject) __dealloc_zombie] + 159 10 libios_test_flutter.dylib 0x000000014b635fea -[FlutterEngine dealloc] + 334 11 libobjc.A.dylib 0x00007ff800055228 _ZN11objc_object17sidetable_releaseEbb + 204 12 libios_test_flutter.dylib 0x000000014b63eda9 _ZNSt3_fl10__function6__funcIZ30-[FlutterEngine startProfiler]E3$_0NS_9allocatorIS2_EEFN7flutter13ProfileSampleEvEEclEv + 69 13 libios_test_flutter.dylib 0x000000014bcd8eaa _ZNSt3_fl10__function6__funcIZNK7flutter16SamplingProfiler16SampleRepeatedlyEN3fml9TimeDeltaEE3$_0NS_9allocatorIS6_EEFvvEEclEv + 40 14 libios_test_flutter.dylib 0x000000014b868786 _ZN3fml15MessageLoopImpl10FlushTasksENS_9FlushTypeE + 156 15 libios_test_flutter.dylib 0x000000014b86ecca _ZN3fml17MessageLoopDarwin11OnTimerFireEP16__CFRunLoopTimerPS0_ + 26 16 CoreFoundation 0x00007ff8003ea4a5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20 17 CoreFoundation 0x00007ff8003ea032 __CFRunLoopDoTimer + 801 18 CoreFoundation 0x00007ff8003e97b6 __CFRunLoopDoTimers + 243 19 CoreFoundation 0x00007ff8003e4028 __CFRunLoopRun + 2108 20 CoreFoundation 0x00007ff8003e3409 CFRunLoopRunSpecific + 557 21 libios_test_flutter.dylib 0x000000014b86ee07 _ZN3fml17MessageLoopDarwin3RunEv + 65 22 libios_test_flutter.dylib 0x000000014b8686a4 _ZN3fml15MessageLoopImpl5DoRunEv + 22 23 libios_test_flutter.dylib 0x000000014b86dce5 _ZNSt3_fl10__function6__funcIZN3fml6ThreadC1ERKNS_8functionIFvRKNS3_12ThreadConfigEEEES7_E3$_0NS_9allocatorISC_EEFvvEEclEv + 135 24 libios_test_flutter.dylib 0x000000014b86da87 _ZZN3fml12ThreadHandleC1EONSt3_fl8functionIFvvEEEEN3$_08__invokeEPv + 27 25 libsystem_pthread.dylib 0x000000010d6a818b _pthread_start + 99 26 libsystem_pthread.dylib 0x000000010d6a3ae3 thread_start + 15 2024-10-18 09:31:27.549111-0700 IosUnitTests[46919:333147] [reports] Main Thread Checker: UI API called on a background thread: -[UIView removeFromSuperview] PID: 46919, TID: 333147, Thread name: FlutterEngine.166.profiler, Queue name: com.apple.root.default-qos.overcommit, QoS: 0 Backtrace: 4 libios_test_flutter.dylib 0x000000014b658aed -[FlutterTextInputPlugin dealloc] + 27 5 libobjc.A.dylib 0x00007ff800055228 _ZN11objc_object17sidetable_releaseEbb + 204 6 libios_test_flutter.dylib 0x000000014b63df5a -[FlutterEngine .cxx_destruct] + 135 7 libobjc.A.dylib 0x00007ff800035766 _ZL27object_cxxDestructFromClassP11objc_objectP10objc_class + 83 8 libobjc.A.dylib 0x00007ff80004ddfc objc_destructInstance + 61 9 CoreFoundation 0x00007ff8004a286b -[NSObject(NSObject) __dealloc_zombie] + 159 10 libios_test_flutter.dylib 0x000000014b635fea -[FlutterEngine dealloc] + 334 11 libobjc.A.dylib 0x00007ff800055228 _ZN11objc_object17sidetable_releaseEbb + 204 12 libios_test_flutter.dylib 0x000000014b63eda9 _ZNSt3_fl10__function6__funcIZ30-[FlutterEngine startProfiler]E3$_0NS_9allocatorIS2_EEFN7flutter13ProfileSampleEvEEclEv + 69 13 libios_test_flutter.dylib 0x000000014bcd8eaa _ZNSt3_fl10__function6__funcIZNK7flutter16SamplingProfiler16SampleRepeatedlyEN3fml9TimeDeltaEE3$_0NS_9allocatorIS6_EEFvvEEclEv + 40 14 libios_test_flutter.dylib 0x000000014b868786 _ZN3fml15MessageLoopImpl10FlushTasksENS_9FlushTypeE + 156 15 libios_test_flutter.dylib 0x000000014b86ecca _ZN3fml17MessageLoopDarwin11OnTimerFireEP16__CFRunLoopTimerPS0_ + 26 16 CoreFoundation 0x00007ff8003ea4a5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20 17 CoreFoundation 0x00007ff8003ea032 __CFRunLoopDoTimer + 801 18 CoreFoundation 0x00007ff8003e97b6 __CFRunLoopDoTimers + 243 19 CoreFoundation 0x00007ff8003e4028 __CFRunLoopRun + 2108 20 CoreFoundation 0x00007ff8003e3409 CFRunLoopRunSpecific + 557 21 libios_test_flutter.dylib 0x000000014b86ee07 _ZN3fml17MessageLoopDarwin3RunEv + 65 22 libios_test_flutter.dylib 0x000000014b8686a4 _ZN3fml15MessageLoopImpl5DoRunEv + 22 23 libios_test_flutter.dylib 0x000000014b86dce5 _ZNSt3_fl10__function6__funcIZN3fml6ThreadC1ERKNS_8functionIFvRKNS3_12ThreadConfigEEEES7_E3$_0NS_9allocatorISC_EEFvvEEclEv + 135 24 libios_test_flutter.dylib 0x000000014b86da87 _ZZN3fml12ThreadHandleC1EONSt3_fl8functionIFvvEEEEN3$_08__invokeEPv + 27 25 libsystem_pthread.dylib 0x000000010d6a818b _pthread_start + 99 26 libsystem_pthread.dylib 0x000000010d6a3ae3 thread_start + 15 IosUnitTests(47009,0x10ec76240) malloc: enabling scribbling to detect mods to free blocks IosUnitTests(47009) MallocStackLogging: could not tag MSL-related memory as no_footprint, so those pages will be included in process footprint - (null) IosUnitTests(47009) MallocStackLogging: stack logs being written to /private/tmp/stack-logs.47009.1057b6000.IosUnitTests.0o4HgN.index IosUnitTests(47009) MallocStackLogging: recording malloc and VM allocation stacks to disk using standard recorder IosUnitTests(47009) MallocStackLogging: process 46919 no longer exists, stack logs deleted from /tmp/stack-logs.46919.10d1fc000.IosUnitTests.kFionm.index ``` This reverts commit 02fc8a4. ## Pre-launch Checklist - [X] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [X] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [X] I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides]. - [X] I listed at least one issue that this PR fixes in the description above. - [X] I added new tests to check the change I am making or feature I am adding, or the PR is [test-exempt]. See [testing the engine] for instructions on writing and running engine tests. - [X] I updated/added relevant documentation (doc comments with `///`). - [X] I signed the [CLA]. - [X] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style [testing the engine]: https://github.com/flutter/flutter/wiki/Testing-the-engine [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat
nick9822
pushed a commit
to nick9822/flutter
that referenced
this pull request
Dec 18, 2024
This reverts commit 773c37a. This relands commit a2ac734. Migrates `FlutterEngine` from manual reference counting to ARC. Migrates properties from `retain` to strong and `assign` to `weak` (where referencing an Obj-C object). Includes two additional fixes on top of the original: * In `waitForFirstFrame:callback:` we ensure FlutterEngine isn't released on a background thread, but instead is always freed on the platform thread. * In `testViewControllerIsReleased` we call loadView prior to calling `viewDidLoad`. `viewDidLoad` calls `[FlutterEngine attachView]` which calls `[PlatformViewIOS::attachView]` which asserts that the view is loaded. No semantic changes, therefore no changes to tests. Issue: flutter#137801 Issue: flutter#156177 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This reverts commit 2484ae1.
This relands commit 449df25.
Migrates
FlutterEnginefrom manual reference counting to ARC. Migrates properties fromretainto strong andassigntoweak(where referencing an Obj-C object).Includes two additional fixes on top of the original:
waitForFirstFrame:callback:we ensure FlutterEngine isn't released on a background thread, but instead is always freed on the platform thread.testViewControllerIsReleasedwe call loadView prior to callingviewDidLoad.viewDidLoadcalls[FlutterEngine attachView]which calls[PlatformViewIOS::attachView]which asserts that the view is loaded.No semantic changes, therefore no changes to tests.
Issue: flutter/flutter#137801
Issue: flutter/flutter#156177
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.