@@ -884,31 +884,31 @@ - (void)_invalidateModules
884
884
shouldPerfLog: NO ];
885
885
886
886
if ([module respondsToSelector: @selector (invalidate )]) {
887
- if ([module respondsToSelector: @selector (methodQueue )]) {
888
- dispatch_queue_t methodQueue = [module performSelector: @selector (methodQueue )];
889
-
890
- if (methodQueue) {
891
- dispatch_group_enter (moduleInvalidationGroup);
892
- dispatch_block_t invalidateModule = ^{
893
- [((id <RCTInvalidating>)module) invalidate ];
894
- dispatch_group_leave (moduleInvalidationGroup);
895
- };
896
-
897
- if (_bridge) {
898
- [_bridge dispatchBlock: invalidateModule queue: methodQueue];
899
- } else {
900
- // Bridgeless mode
901
- if (methodQueue == RCTJSThread) {
902
- invalidateModule ();
903
- } else {
904
- dispatch_async (methodQueue, invalidateModule);
905
- }
906
- }
907
- continue ;
908
- }
887
+ dispatch_queue_t methodQueue = (dispatch_queue_t )objc_getAssociatedObject (module, &kAssociatedMethodQueueKey );
888
+
889
+ if (methodQueue == nil ) {
890
+ RCTLogError (
891
+ @" TurboModuleManager: Couldn't invalidate TurboModule \" %@ \" , because its method queue is nil." ,
892
+ [module class ]);
893
+ continue ;
909
894
}
910
895
911
- [((id <RCTInvalidating>)module) invalidate ];
896
+ dispatch_group_enter (moduleInvalidationGroup);
897
+ dispatch_block_t invalidateModule = ^{
898
+ [((id <RCTInvalidating>)module) invalidate ];
899
+ dispatch_group_leave (moduleInvalidationGroup);
900
+ };
901
+
902
+ if (_bridge) {
903
+ [_bridge dispatchBlock: invalidateModule queue: methodQueue];
904
+ } else {
905
+ // Bridgeless mode
906
+ if (methodQueue == RCTJSThread) {
907
+ invalidateModule ();
908
+ } else {
909
+ dispatch_async (methodQueue, invalidateModule);
910
+ }
911
+ }
912
912
}
913
913
}
914
914
0 commit comments