Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flutter - Hot restart in console causes iOS Dropbox to crash #24

Open
PKiman opened this issue Aug 30, 2023 · 1 comment
Open

Flutter - Hot restart in console causes iOS Dropbox to crash #24

PKiman opened this issue Aug 30, 2023 · 1 comment

Comments

@PKiman
Copy link
Contributor

PKiman commented Aug 30, 2023

The use of Hot restart function in the console causes Dropbox iOS library to crash.

Related issue:
Hot Restart does not dispose native iOS/Android plugins.
flutter/flutter#69949

Dropbox iOS client library forces app crash:
(Bad software design I think. Should be just a warning.)

NSAssert(![DBOAuthManager sharedOAuthManager], @"Only call `[DBClientsManager setupWith...]` once");

https://github.com/dropbox/dropbox-sdk-obj-c/blob/0d6f0bac2519f1e36b4f9c19c108eb50ca3a59be/Source/ObjectiveDropboxOfficial/Shared/Handwritten/DBClientsManager.m#L104

Steps:

  1. Init Dropbox Library via flutter iOS (Simulator/iPhone)
  2. Press Shift+R in the console for hot restart the application
    Observed:
*** Assertion failure in +[DBClientsManager setupWithOAuthManager:transportConfig:], DBClientsManager.m:106
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Only call `[DBClientsManager setupWith...]` once'
*** First throw call stack:
(0x195c31e48 0x18eefb8d8 0x1904ea94c 0x1058f6b68 0x1058f86e0 0x1058f85e0 0x102e3eacc 0x109ce276c 0x10973cb80 0x19d2434b4 0x19d244fdc 0x19d2537f4 0x19d253444 0x195cc26d8 0x195ca403c 0x195ca8ec0 0x1cfcff368 0x19819e86c 0x19819e4d0 0x102653e68 0x1b44ca960)
libc++abi: terminating with uncaught exception of type NSException
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00000001d35a3160 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`:
->  0x1d35a3160 <+8>:  b.lo   0x1d35a3180               ; <+40>
    0x1d35a3164 <+12>: pacibsp 
    0x1d35a3168 <+16>: stp    x29, x30, [sp, #-0x10]!
    0x1d35a316c <+20>: mov    x29, sp
Target 0: (Runner) stopped.

Solution 1:
check static sharedOAuthManager if it has been initialised already and exit.
file: DropboxPlugin.m

    } else if ([@"init" isEqualToString:call.method]) {
//        NSString *clientId = call.arguments[@"clientId"];
        NSString *key = call.arguments[@"key"];
//        NSString *secret = call.arguments[@"secret"];
        if ([DBOAuthManager sharedOAuthManager]) {
          NSLog(@"Already initialized with appKey %@", appKey);
          result(@(TRUE));
          return;
        }
        appKey = key;

Solution 2:
Remove NSAssert from the dropbox library:
https://github.com/dropbox/dropbox-sdk-obj-c/blob/0d6f0bac2519f1e36b4f9c19c108eb50ca3a59be/Source/ObjectiveDropboxOfficial/Shared/Handwritten/DBClientsManager.m#L104

@PKiman
Copy link
Contributor Author

PKiman commented Aug 30, 2023

Here the related PR
Hot restart works for me.

Can someone review?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant