darwin-morocho / flutter-facebook-auth

A flutter plugin to add login with facebook in your flutter app
191 stars 124 forks source link

[macOS] Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'dismissViewController:: Error: maybe this view controller was not presented?' #389

Closed potatojoayo closed 2 months ago

potatojoayo commented 2 months ago

What version are you using?

flutter_facebook_auth:6.0.4, facebook_auth_desktop: 1.0.2

What OS and version are you using to local deploy your application?

macOS 14.2.1

What platforms are you seeing the problem on?

macOS

pubspec.yaml

name: plain_auth
description: "Plain Potato authentication package."
version: 0.0.1
#homepage:

environment:
  sdk: '>=3.2.5 <4.0.0'
  flutter: ">=1.17.0"

dependencies:
  crypto: ^3.0.3
  easy_localization: ^3.0.3
  equatable: ^2.0.5
  facebook_auth_desktop: ^1.0.2
  firebase_auth: ^4.17.0
  flutter:
    sdk: flutter
  flutter_bloc: ^8.1.3
  flutter_facebook_auth: ^6.0.4
  font_awesome_flutter: ^10.7.0
  google_sign_in: ^6.2.1
  hydrated_bloc: ^9.1.3
  sign_in_with_apple: ^5.0.0

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^2.0.0
  mocktail: ^1.0.3
  bloc_test: ^9.1.5

flutter:

Describe the Bug

After login in a new window, the following error was created.

2024-02-14 18:40:07.604 plain_todo[12118:3781912] *** Assertion failure in -[facebook_auth_desktop.WebViewController dismissViewController:], NSViewController.m:863
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'dismissViewController:: Error: maybe this view controller was not presented?'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000018db9c570 __exceptionPreprocess + 176
    1   libobjc.A.dylib                     0x000000018d68deb4 objc_exception_throw + 60
    2   Foundation                          0x000000018ece443c -[NSCalendarDate initWithCoder:] + 0
    3   AppKit                              0x00000001918080ac -[NSViewController dismissViewController:] + 224
    4   facebook_auth_desktop               0x0000000101423124 $s21facebook_auth_desktop17WebViewControllerC03webE0_15decidePolicyFor15decisionHandlerySo05WKWebE0C_So18WKNavigationActionCySo0noI0VctF + 1488
    5   facebook_auth_desktop               0x000000010142327c $s21facebook_auth_desktop17WebViewControllerC03webE0_15decidePolicyFor15decisionHandlerySo05WKWebE0C_So18WKNavigationActionCySo0noI0VctFTo + 140
    6   WebKit                              0x00000001b0ae3248 _ZN6WebKit15NavigationState16NavigationClient31decidePolicyForNavigationActionERNS_12WebPageProxyEON3WTF3RefIN3API16NavigationActionENS4_12RawPtrTraitsIS7_EEEEONS5_INS_27WebFramePolicyListenerPro  7   WebKit                              0x00000001b0cb9a94 _ZN6WebKit12WebPageProxy31decidePolicyForNavigationActionEON3WTF3RefINS_15WebProcessProxyENS1_12RawPtrTraitsIS3_EEEENS1_23ObjectIdentifierGenericIN7WebCore18PageIdentifierTypeENS1_38ObjectIdentif  8   WebKit                              0x00000001b0cb88bc _ZN6WebKit12WebPageProxy42decidePolicyForNavigationActionAsyncSharedEON3WTF3RefINS_15WebProcessProxyENS1_12RawPtrTraitsIS3_EEEENS1_23ObjectIdentifierGenericIN7WebCore18PageIdentifierTypeENS1_38Ob  9   WebKit                              0x00000001b0cb8724 _ZN6WebKit12WebPageProxy36decidePolicyForNavigationActionAsyncEONS_13FrameInfoDataEyONS_20NavigationActionDataES2_NSt3__18optionalIN3WTF23ObjectIdentifierGenericINS_26WebPageProxyIdentifierTypeEN  10  WebKit                              0x00000001b108f4a8 _ZN6WebKit12WebPageProxy17didReceiveMessageERN3IPC10ConnectionERNS1_7DecoderE + 1016
    11  WebKit                              0x00000001b115a15c _ZN3IPC18MessageReceiverMap15dispatchMessageERNS_10ConnectionERNS_7DecoderE + 264
    12  WebKit                              0x00000001b0d0c50c _ZN6WebKit15WebProcessProxy17didReceiveMessageERN3IPC10ConnectionERNS1_7DecoderE + 40
    13  WebKit                              0x00000001b11550e4 _ZN3IPC10Connection15dispatchMessageENSt3__110unique_ptrINS_7DecoderENS1_14default_deleteIS3_EEEE + 324
    14  WebKit                              0x00000001b1155530 _ZN3IPC10Connection24dispatchIncomingMessagesEv + 496
    15  JavaScriptCore                      0x00000001a9939ad8 _ZN3WTF7RunLoop11performWorkEv + 204
    16  JavaScriptCore                      0x00000001a993a9a8 _ZN3WTF7RunLoop11performWorkEPv + 36
    17  CoreFoundation                      0x000000018db27a4c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
    18  CoreFoundation                      0x000000018db279e0 __CFRunLoopDoSource0 + 176
    19  CoreFoundation                      0x000000018db27750 __CFRunLoopDoSources0 + 244
    20  CoreFoundation                      0x000000018db26340 __CFRunLoopRun + 828
    21  CoreFoundation                      0x000000018db259ac CFRunLoopRunSpecific + 608
    22  HIToolbox                           0x00000001980d4448 RunCurrentEventLoopInMode + 292
    23  HIToolbox                           0x00000001980d4284 ReceiveNextEventCommon + 648
    24  HIToolbox                           0x00000001980d3fdc _BlockUntilNextEventMatchingListInModeWithFilter + 76
    25  AppKit                              0x00000001913028a4 _DPSNextEvent + 660
    26  AppKit                              0x0000000191adc980 -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 716
    27  AppKit                              0x00000001912f5d50 -[NSApplication run] + 476
    28  AppKit                              0x00000001912cd014 NSApplicationMain + 880
    29  plain_todo                          0x0000000100d944b8 main + 12
    30  dyld                                0x000000018d6c90e0 start + 2360
)
libc++abi: terminating due to uncaught exception of type NSException
Lost connection to device.
the Dart compiler exited unexpectedly.

Expected Behavior

No error.

To Reproduce

    final LoginResult loginResult;

    if (defaultTargetPlatform == TargetPlatform.macOS) {
      _plugin = FacebookAuthDesktopPlugin();
      _plugin.webAndDesktopInitialize(
          appId: '3823348807877566',
          cookie: true,
          xfbml: true,
          version: 'v18.0');

      loginResult = await _plugin.login();
    } else {
      loginResult = await _facebookAuth.login();
    }

Relevant log output

No response

flutter doctor -v

[✓] Flutter (Channel stable, 3.16.9, on macOS 14.2.1 23C71 darwin-arm64, locale ko-KR)
    • Flutter version 3.16.9 on channel stable at /Users/hanhyobeom/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 41456452f2 (3 weeks ago), 2024-01-25 10:06:23 -0800
    • Engine revision f40e976bed
    • Dart version 3.2.6
    • DevTools version 2.28.5

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/hanhyobeom/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15C500b
    • CocoaPods version 1.14.3

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

[✓] Android Studio (version 2023.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
    • android-studio-dir = /Applications/Android Studio.app
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] Connected device (3 available)            
    • iPhone (4) (mobile) • 00008030-001845C40E83802E • ios            • iOS 17.2.1 21C66
    • macOS (desktop)     • macos                     • darwin-arm64   • macOS 14.2.1 23C71 darwin-arm64
    • Chrome (web)        • chrome                    • web-javascript • Google Chrome 121.0.6167.160

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Info.plist (iOS)

No response

Podfile (iOS)

No response

AndroidManifest.xml

No response

MainActivity.java

No response

MainActivity.kt

No response

index.html

No response

Info.plist (macOS)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CADisableMinimumFrameDurationOnPhone</key>
    <true/>
    <key>CFBundleDevelopmentRegion</key>
    <string>$(DEVELOPMENT_LANGUAGE)</string>
    <key>CFBundleDisplayName</key>
    <string>Plain Todo</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleLocalizations</key>
    <array>
        <string>en</string>
        <string>ko</string>
    </array>
    <key>CFBundleName</key>
    <string>Plain TODO</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>$(FLUTTER_BUILD_NAME)</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fb***</string>

            </array>
        </dict>
    </array>
    <key>CFBundleVersion</key>
    <string>$(FLUTTER_BUILD_NUMBER)</string>
    <key>FacebookAppID</key>
    <string>***</string>
    <key>FacebookClientToken</key>
    <string>***<string>
    <key>FacebookDisplayName</key>
    <string>Plain Potato</string>
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>fbapi</string>
        <string>fb-messenger-share-api</string>
    </array>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>UIApplicationSupportsIndirectInputEvents</key>
    <true/>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
    </array>
    <key>keychain-access-groups</key>
    <array>
        <string>$(AppIdentifierPrefix)com.google.GIDSignIn</string>
    </array>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsLocalNetworking</key>
        <true/>
    </dict>
</dict>
</plist>
potatojoayo commented 2 months ago

Created a pull request

390