Skip to content

[Video player plugin] crashes with new pigeon version when engine is detached #56996

@dannyvalentesonos

Description

@dannyvalentesonos

The latest video player tries to set the message handler to nil on all the channels in the messages.m file when the FlutterEngine gets deallocated. The following code from the video player doe sthat:

- (void)detachFromEngineForRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
  for (NSNumber* textureId in _players.allKeys) {
    FLTVideoPlayer* player = _players[textureId];
    [player disposeSansEventChannel];
  }
  [_players removeAllObjects];
  FLTVideoPlayerApiSetup(registrar.messenger, nil);
}

However, by this time, the engine is not running, and this causes an exception:

2020-05-12 08:51:58.023258-0400[10094:37996] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Setting a message handler before the FlutterEngine has been run.'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000010dd416fb __exceptionPreprocess + 331
	1   libobjc.A.dylib                     0x000000010bf7bac5 objc_exception_throw + 48
	2   CoreFoundation                      0x000000010dd41482 +[NSException raise:format:arguments:] + 98
	3   Foundation                          0x000000010b9c9927 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 194
	4   Flutter                             0x0000000110cdbb31 -[FlutterEngine setMessageHandlerOnChannel:binaryMessageHandler:] + 264
	5   MyApp                               0x000000010560b23a _Z22FLTVideoPlayerApiSetupPU33objcproto22FlutterBinaryMessenger11objc_objectPU28objcproto17FLTVideoPlayerApi11objc_object + 362
	6   MyApp                               0x00000001056dbd9e -[FLTVideoPlayerPlugin detachFromEngineForRegistrar:] + 766
	7   CoreFoundation                      0x000000010ddb19c2 -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 226
	8   Flutter                             0x0000000110cd8e56 -[FlutterEngine dealloc] + 92

Metadata

Metadata

Assignees

Labels

engineflutter/engine related. See also e: labels.p: pigeonrelated to pigeon messaging codegen toolp: video_playerThe Video Player pluginpackageflutter/packages repository. See also p: labels.will need additional triageThis issue or PR needs attention before being routed to secondary triage

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions