Repository navigation
Closed
flutter-team-archive/engine
#30835Labels
c: crashStack traces logged to the consoleStack traces logged to the consolec: fatal crashCrashes that terminate the processCrashes that terminate the processengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.platform-iosiOS applications specificallyiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Description
Steps to Reproduce
I am using the Flutter 2.5.3, But after Flutter upgrade, I met the Mutex Lock Failed crash. In order to resolve this crash, I decide to apply below changes according to this Fix PR:
// FlutterViewController+Patch.m
+ (void)load {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
SEL origSel = @selector(setupNotificationCenterObservers);
SEL swizSel = @selector(fix_setupNotificationCenterObservers);
Method origMethod = class_getInstanceMethod([self class], origSel);
Method swizMethod = class_getInstanceMethod([self class], swizSel);
method_exchangeImplementations(origMethod, swizMethod);
});
}
- (void)fix_setupNotificationCenterObservers {
[self fix_setupNotificationCenterObservers];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationWillTerminate:)
name:UIApplicationWillTerminateNotification
object:nil];
}
- (void)applicationWillTerminate:(NSNotification*)notification {
BOOL performPatch = NO;
id delegate = UIApplication.sharedApplication.delegate;
if ([delegate respondsToSelector:@selector(isDestroyContext)]) {
performPatch = [delegate performSelector:@selector(isDestroyContext)];
}
if (!performPatch) {
return;
}
if (![self respondsToSelector:@selector(goToApplicationLifecycle:)]) {
return;
}
[self goToApplicationLifecycle:@"AppLifecycleState.detached"];
[self.engine destroyContext];
}After applying these changes to My Project, a new crash are random reported, you can checkout the stacktrack detail at below section.
Expected results:
There is no crash when teminating.
Actual results:
Crashed: com.apple.main-thread
0 Flutter 0x34531c flutter::Shell::OnPlatformViewSetSemanticsEnabled(bool) + 4512371484
1 Flutter 0x41d0c flutter::PlatformViewIOS::~PlatformViewIOS() + 4509211916
2 Flutter 0x3fac0 flutter::PlatformViewIOS::~PlatformViewIOS() + 4509203136
3 Flutter 0x353618 std::__1::__function::__func<fml::internal::CopyableLambda<flutter::Shell::~Shell()::$_6>, std::__1::allocator<fml::internal::CopyableLambda<flutter::Shell::~Shell()::$_6> >, void ()>::operator()() + 4512429592
4 Flutter 0x353000 flutter::Shell::~Shell() + 4512428032
5 Flutter 0x16288 std::__1::unique_ptr<flutter::Shell, std::__1::default_delete<flutter::Shell> >::reset(flutter::Shell*) + 4509033096
6 Flutter 0x12850 -[FlutterEngine destroyContext] + 4509018192
7 Binance 0x5240 -[FlutterViewController(Patch) applicationWillTerminate:] + 52 (FlutterViewController+Patch.m:52)
8 CoreFoundation 0x2af88 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 28
9 CoreFoundation 0xc6c3c ___CFXRegistrationPost_block_invoke + 52
10 CoreFoundation 0x99ff4 _CFXRegistrationPost + 456
11 CoreFoundation 0x40df4 _CFXNotificationPost + 716
12 Foundation 0x1af68 -[NSNotificationCenter postNotificationName:object:userInfo:] + 96
13 UIKitCore 0xf54654 -[UIApplication _terminateWithStatus:] + 300
14 UIKitCore 0x63cb38 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 128
15 UIKitCore 0x831a80 -[_UISceneLifecycleMultiplexer forceExitWithTransitionContext:scene:] + 224
16 UIKitCore 0xf5129c -[UIApplication workspaceShouldExit:withTransitionContext:] + 212
17 FrontBoardServices 0x4f780 __63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke_2 + 80
18 FrontBoardServices 0xa06c -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 240
19 FrontBoardServices 0x4f718 __63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke + 132
20 libdispatch.dylib 0x4670 _dispatch_client_callout + 20
21 libdispatch.dylib 0x8128 _dispatch_block_invoke_direct + 264
22 FrontBoardServices 0xb9c4 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 48
23 FrontBoardServices 0xad8c -[FBSSerialQueue _targetQueue_performNextIfPossible] + 220
24 FrontBoardServices 0xf414 -[FBSSerialQueue _performNextFromRunLoopSource] + 28
25 CoreFoundation 0xbb0d0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
26 CoreFoundation 0xcbd90 __CFRunLoopDoSource0 + 208
27 CoreFoundation 0x6104 __CFRunLoopDoSources0 + 376
28 CoreFoundation 0xb8a4 __CFRunLoopRun + 820
29 CoreFoundation 0x1f468 CFRunLoopRunSpecific + 600
30 GraphicsServices 0x138c GSEventRunModal + 164
31 UIKitCore 0x51a088 -[UIApplication _run] + 1100
32 UIKitCore 0x298958 UIApplicationMain + 2092
33 Binance 0x5890 main + 14 (main.swift:14)
34 ??? 0x10ab4daa4 (缺少)
Code sample
Logs
[✓] Flutter (Channel unknown, 2.5.3, on macOS 11.6.1 20G224 darwin-x64, locale zh-Hans-CN)
• Flutter version 2.5.3 at /Users/user/.flutter_wrapper/2.5.3
• Upstream repository unknown
• Framework revision 18116933e7 (2 months ago), 2021-10-15 10:46:35 -0700
• Engine revision d3ea636dc5
• Dart version 2.14.4
[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, please use
`flutter config --android-sdk` to update to that location.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 13.2.1, Build version 13C100
• CocoaPods version 1.11.0
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[!] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
[✓] VS Code (version 1.63.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.29.0
[✓] Connected device (2 available)
• iPhone 8 (mobile) • 79EED0F4-1973-465C-9169-9BAA07880B38 • ios • com.apple.CoreSimulator.SimRuntime.iOS-15-2 (simulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.110
! Doctor found issues in 2 categories.
Reacted by Bruno Viana de Siqueira, Marcos Rodriguez Toranzo, BansookNam, Roufan Liau, Suguru Kishimoto, Aiman, Tommy, Liber Da Silva, Den, TheJulianJES and 12 more
Metadata
Metadata
Assignees
Labels
c: crashStack traces logged to the consoleStack traces logged to the consolec: fatal crashCrashes that terminate the processCrashes that terminate the processengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.platform-iosiOS applications specificallyiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Activity
brunovsiqueira commentedon Dec 27, 2021
Same crash happening here in production with several users.
darshankawar commentedon Dec 28, 2021
@flutter-symbolizer-bot #95844 (comment) force ios arm64 release flutter#v2.5.3
flutter-symbolizer-bot commentedon Dec 28, 2021
crash from #95844 (comment) symbolized using symbols for
d3ea636dc5d16b56819f3266241e1f708979c233ios-arm64-release(Load address missing from the report, detected heuristically: 0000000000000000)
darshankawar commentedon Dec 28, 2021
Keeping it open and labeling for further investigation.
Maybe similar / related to #95568
/cc @chinmaygarde
zhongwuzw commentedon Dec 28, 2021
@Maru-zhang Hi. How many crashes of this new crash compared to
Mutex Lock Failed crash. Is it decrease or increase?From the crash log, seems engine not reset successfully.
Maru-zhang commentedon Dec 29, 2021
@zhongwuzw Hi zhongwuzw, thanks for your help. We use gray release to apply these changes, only 1% our user cause about 40+ crash. So I think The Order of Magnitude Estimate is same, since
Mutex Lock Failed crashcause about 4000+ crash in our project.zhongwuzw commentedon Dec 30, 2021
@Maru-zhang Thanks for your useful information.
From the crash log, seems
_enginenot reset successfully, see https://github.com/flutter/engine/blob/fa558f6a7ea694caff289d9e589b576a8515ea9b/shell/common/shell.cc#L446, andengine_->GetWeakPtr()not returnnullptr, see https://github.com/flutter/engine/blob/fa558f6a7ea694caff289d9e589b576a8515ea9b/shell/common/shell.cc#L975. @chinmaygarde Would you help to have a look?37 remaining items
BansookNam commentedon Feb 14, 2022
unfortunately regarding #95568 (comment)
the problem still exists on 2.10.1 too.
Please leave a comment if anyone finds the same one. 🙏
itsjustkevin commentedon Feb 14, 2022
@gaaclarke this is a good Idea, will add it to the documentation.
gwennguihal commentedon Feb 25, 2022
If it can help:
jmagman commentedon Feb 25, 2022
Reopening--as @gaaclarke said the engine beta cherrypick was 74b74b10ea6 which included this fix. That was SHA upgraded to in 73adb14, which is in 2.10. Quite a few reports of this still happening on >2.10.
jmagman commentedon Feb 25, 2022
@jason-simmons
jason-simmons commentedon Feb 25, 2022
On older versions of the engine I could reproduce this crash by enabling VoiceOver and then stopping the app in the App Switcher. But I do not see this happening on 2.10.0 or 2.10.2.
Does anyone have a way to reproduce the
OnPlatformViewSetSemanticsEnabledcrash on a 2.10.x release or on the Flutter master branch?gwennguihal commentedon Feb 26, 2022
Sorry, I was effectively on 2.8 on the simulator. I will try quickly on 2.10.x
chinmaygarde commentedon Feb 28, 2022
Closing this issue as this has been fixed. If this happens on releases after 2.10.2, please file a separate issue.
LoyaltyWu commentedon Mar 1, 2022
Is this issue related to #96850?
github-actions commentedon Mar 15, 2022
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.