google / flutter-desktop-embedding

Experimental plugins for Flutter for Desktop
Apache License 2.0
7.1k stars 604 forks source link

App crashes if first minimize the window and then call setWindowVisibility(visible: true) #890

Closed RaphaelRevivor closed 2 years ago

RaphaelRevivor commented 2 years ago

Is this a bug in one of the plugins in this project?

Which plugin is this bug report about?

window_size

Describe the bug

I was trying to use: setWindowVisibility(visible: true); to show and put focus on the window. However when I minimized the window at first, then called setWindowVisibility(visible: true), an error was thrown and the app aborted. The following are the error messages:

Error Messages 2021-10-09 23:12:57.047 foca_macos_new[88708:621218] *** Assertion failure in -[FlutterViewController listenForMetaModifiedKeyUpEvents], ../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm:383 2021-10-09 23:12:57.070 foca_macos_new[88708:621218] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '_keyUpMonitor was already created' *** First throw call stack: ( 0 CoreFoundation 0x00007ff8122e3c3b __exceptionPreprocess + 242 1 libobjc.A.dylib 0x00007ff81204adce objc_exception_throw + 48 2 Foundation 0x00007ff8130bbd73 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 267 3 FlutterMacOS 0x0000000114ab2f2c -[FlutterViewController listenForMetaModifiedKeyUpEvents] + 380 4 FlutterMacOS 0x0000000114ab2b55 -[FlutterViewController viewWillAppear] + 117 5 AppKit 0x00007ff814ce3d11 -[NSViewController _sendViewWillAppear] + 40 6 AppKit 0x00007ff814ce9c4d -[NSViewController _windowDidOrderOnScreen] + 107 7 AppKit 0x00007ff81541c319 -[NSView _windowDidOrderOnScreen] + 67 8 AppKit 0x00007ff81541c3af -[NSView _windowDidOrderOnScreen] + 217 9 AppKit 0x00007ff814ce1f7d -[NSWindow _reallyDoOrderWindowAboveOrBelow:relativeTo:findKey:forCounter:force:isModal:] + 2034 10 AppKit 0x00007ff814ce1436 -[NSWindow _reallyDoOrderWindow:relativeTo:findKey:forCounter:force:isModal:] + 135 11 AppKit 0x00007ff814ce042b -[NSWindow _doOrderWindow:relativeTo:findKey:forCounter:force:isModal:] + 289 12 AppKit 0x00007ff814ce02a9 -[NSWindow orderWindow:relativeTo:] + 152 13 AppKit 0x00007ff814cd4e90 -[NSWindow makeKeyAndOrderFront:] + 60 14 window_size 0x0000000109d3caf4 -[FLEWindowSizePlugin handleMethodCall:result:] + 8724 15 FlutterMacOS 0x0000000114a9e0ad __56-[FlutterEngineRegistrar addMethodCallDelegate:channel:]_block_invoke + 45 16 FlutterMacOS 0x000000011568ba97 __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 119 17 FlutterMacOS 0x0000000114aa06a1 -[FlutterEngine engineCallbackOnPlatformMessage:] + 289 18 FlutterMacOS 0x0000000114a9eeac _ZL17OnPlatformMessagePK22FlutterPlatformMessageP13FlutterEngine + 44 19 FlutterMacOS 0x00000001152d7fbd _ZNSt3__110__function6__funcIZ23FlutterEngineInitializeE4$_49NS_9allocatorIS2_EEFvNS_10unique_ptrIN7flutter15PlatformMessageENS_14default_deleteIS7_EEEEEEclEOSA_ + 141 20 FlutterMacOS 0x00000001152e920a _ZN7flutter20PlatformViewEmbedder21HandlePlatformMessageENSt3__110unique_ptrINS_15PlatformMessageENS1_14default_deleteIS3_EEEE + 74 21 FlutterMacOS 0x0000000115043b84 _ZNSt3__110__function6__funcIN3fml8internal14CopyableLambdaIZN7flutter5Shell29OnEngineHandlePlatformMessageENS_10unique_ptrINS5_15PlatformMessageENS_14default_deleteIS8_EEEEE4$_16EENS_9allocatorISD_EEFvvEEclEv + 132 22 FlutterMacOS 0x00000001152e6522 _ZN7flutter18EmbedderTaskRunner8PostTaskEy + 738 23 FlutterMacOS 0x00000001152ce57c FlutterEngineRunTask + 44 24 FlutterMacOS 0x0000000114aa1807 __60-[FlutterEngine postMainThreadTask:targetTimeInNanoseconds:]_block_invoke + 71 25 libdispatch.dylib 0x00007ff811fecfe8 _dispatch_call_block_and_release + 12 26 libdispatch.dylib 0x00007ff811fee1d9 _dispatch_client_callout + 8 27 libdispatch.dylib 0x00007ff811ffa863 _dispatch_main_queue_callback_4CF + 949 28 CoreFoundation 0x00007ff8122a6a18 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9 29 CoreFoundation 0x00007ff812268066 __CFRunLoopRun + 2760 30 CoreFoundation 0x00007ff812266ec9 CFRunLoopRunSpecific + 567 31 HIToolbox 0x00007ff81b3398a1 RunCurrentEventLoopInMode + 292 32 HIToolbox 0x00007ff81b3395f7 ReceiveNextEventCommon + 587 33 HIToolbox 0x00007ff81b339395 _BlockUntilNextEventMatchingListInModeWithFilter + 70 34 AppKit 0x00007ff814ba9290 _DPSNextEvent + 886 35 AppKit 0x00007ff814ba78fc -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1411 36 AppKit 0x00007ff814b998e5 -[NSApplication run] + 586 37 AppKit 0x00007ff814b6da40 NSApplicationMain + 816 38 foca_macos_new 0x0000000100ab4a1d main + 13 39 dyld 0x0000000200c244d5 start + 421 40 dyld 0x0000000200c1f000 dyld + 0 41 foca_macos_new 0x0000000100aaf000 __dso_handle + 0 ) libc++abi: terminating with uncaught exception of type NSException Lost connection to device. Exited (sigterm)

Flutter doctor

[✓] Flutter (Channel stable, 2.5.0, on macOS 12.0 21A5506j darwin-arm, locale en-SE)
    • Flutter version 2.5.0 at /Users/raphael/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4cc385b4b8 (5 weeks ago), 2021-09-07 23:01:49 -0700
    • Engine revision f0826da7ef
    • Dart version 2.14.0

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/raphael/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.5.1, Build version 12E507
    • CocoaPods version 1.10.0

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.61.0-insider)
    • VS Code at /Applications/Visual Studio Code - Insiders.app/Contents
    • Flutter extension version 3.27.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 12.0 21A5506j darwin-arm
    • Chrome (web)    • chrome • web-javascript • Google Chrome 94.0.4606.71

• No issues found!
stuartmorgan commented 2 years ago

0 CoreFoundation 0x00007ff8122e3c3b __exceptionPreprocess + 242 1 libobjc.A.dylib 0x00007ff81204adce objc_exception_throw + 48 2 Foundation 0x00007ff8130bbd73 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 267 3 FlutterMacOS 0x0000000114ab2f2c -[FlutterViewController listenForMetaModifiedKeyUpEvents] + 380 4 FlutterMacOS 0x0000000114ab2b55 -[FlutterViewController viewWillAppear] + 117

This is a bug in the Flutter engine, not the plugin. Please file a Flutter issue.