Flutter iOS hot restart crash [__NSCFString setStreamHandler:]: unrecognized selector

Viewed 334

For some reasons when I hot restart the app, the app crash with the message :

-[__NSCFString setStreamHandler:]: unrecognized selector sent to instance 0x281a0bb10
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString setStreamHandler:]: unrecognized selector sent to instance 0x281a0bb10'
*** First throw call stack:
(0x18b1b986c 0x1a01d2c50 0x18b0c095c 0x18b1bc438 0x18b1be740 0x104ec6668 0x104ec8610 0x104ed669c 0x104ed4620 0x104ed3674 0x10c4dc694 0x10bc7c038 0x10bf7b41c 0x10bf1a81c 0x10bf1ced4 0x18b135fa0 0x18b135ba0 0x18b134ffc 0x18b12eee4 0x18b12e21c 0x1a2cf8784 0x18db6eee8 0x18db7475c 0x1049c995c 0x18adee6b0)
libc++abi.dylib: terminating with uncaught exception of type NSException
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00000001b9109414 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`__pthread_kill:
->  0x1b9109414 <+8>:  b.lo   0x1b9109434               ; <+40>
    0x1b9109418 <+12>: pacibsp 
    0x1b910941c <+16>: stp    x29, x30, [sp, #-0x10]!
    0x1b9109420 <+20>: mov    x29, sp
Target 0: (Runner) stopped.
Lost connection to device.

I have no idea how to debug it.

Any idea what can cause that ?

1 Answers

Crash is gone for me with patched -[FLTFirebaseAuthPlugin cleanupWithCompletion:] method:

- (void)cleanupWithCompletion:(void (^)(void))completion {
  // Cleanup credentials.
  [_credentials removeAllObjects];

  for (FlutterEventChannel *channel in self->_eventChannels.allValues) {
    [channel setStreamHandler:nil];
  }
  [self->_eventChannels removeAllObjects];
  for (NSObject<FlutterStreamHandler> *handler in self->_streamHandlers.allValues) {
    [handler onCancelWithArguments:nil];
  }
  [self->_streamHandlers removeAllObjects];

  if (completion != nil) completion();
}

The original issue is caused by for..in loop that was iterated over dictionary keys but uses them as values.

More details here

Related