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:
Ramanpreet Nara 2020-07-08 11:47:25 -07:00 коммит произвёл Facebook GitHub Bot
Родитель cfa4260598
Коммит e206e34175
1 изменённых файлов: 6 добавлений и 0 удалений

Просмотреть файл

@ -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();