[ReactNative] Ensure WebViewExecutor's webview is created on the main thread

Summary:
Fixes #2464

After the bridge parallelisation of the bridge initialisation the executors
were being `setUp` in a background thread, and the `RCTWebViewExecutor` was
crashing when creating a `UIWebView` out of the main thread.

Wrap the `UIWebView` creation in a call to the main thread.
This commit is contained in:
Tadeu Zagallo 2015-09-01 05:19:03 -07:00
parent 5b2d8000ae
commit c6240c7441
1 changed files with 6 additions and 4 deletions

View File

@ -66,13 +66,15 @@ RCT_EXPORT_MODULE()
- (void)setUp
{
if (!_webView) {
_webView = [UIWebView new];
[self executeBlockOnJavaScriptQueue:^{
_webView = [UIWebView new];
_webView.delegate = self;
}];
}
_objectsToInject = [NSMutableDictionary new];
_commentsRegex = [NSRegularExpression regularExpressionWithPattern:@"(^ *?\\/\\/.*?$|\\/\\*\\*[\\s\\S]*?\\*\\/)" options:NSRegularExpressionAnchorsMatchLines error:NULL],
_scriptTagsRegex = [NSRegularExpression regularExpressionWithPattern:@"<(\\/?script[^>]*?)>" options:0 error:NULL],
_webView.delegate = self;
_commentsRegex = [NSRegularExpression regularExpressionWithPattern:@"(^ *?\\/\\/.*?$|\\/\\*\\*[\\s\\S]*?\\*\\/)" options:NSRegularExpressionAnchorsMatchLines error:NULL];
_scriptTagsRegex = [NSRegularExpression regularExpressionWithPattern:@"<(\\/?script[^>]*?)>" options:0 error:NULL];
}
- (void)invalidate