Add a warning if TurboModule init uses dispatch_sync for main queue
Summary: When you require a TurboModule on thread that isn't the main thread, but the TurboModule requires main queue setup, we are forced to `dispatch_sync` the set up to the main queue. This is hazardous, because it can lead to deadlocks. Therefore, I'm migrating over a warning from the legacy infra that warns against this use-case. Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D21654637 fbshipit-source-id: 99dc45708c533603d2111fe6163d40e807d2a513
This commit is contained in:
Родитель
cfa4260598
Коммит
e206e34175
|
@ -396,6 +396,12 @@ static Class getFallbackClassFromName(const char *name)
|
|||
};
|
||||
|
||||
if ([self _requiresMainQueueSetup:moduleClass]) {
|
||||
if (!RCTIsMainQueue()) {
|
||||
RCTLogWarn(
|
||||
@"TurboModule \"%@\" requires synchronous dispatch onto the main queue to be initialized. This may lead to deadlock.",
|
||||
moduleClass);
|
||||
}
|
||||
|
||||
RCTUnsafeExecuteOnMainQueueSync(work);
|
||||
} else {
|
||||
work();
|
||||
|
|
Загрузка…
Ссылка в новой задаче