From 44bd5a7306f251503b9f452307586e23f70cf57f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Mon, 28 Dec 2015 18:34:47 +0100 Subject: [PATCH] fix syncContentData to be executed on ui thread --- .../ios/AdvancedEffects/Info.plist | 17 +++++++---------- ios/GLCanvas.m | 11 +++++------ 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/Examples/AdvancedEffects/ios/AdvancedEffects/Info.plist b/Examples/AdvancedEffects/ios/AdvancedEffects/Info.plist index cddf076..ceb55dc 100644 --- a/Examples/AdvancedEffects/ios/AdvancedEffects/Info.plist +++ b/Examples/AdvancedEffects/ios/AdvancedEffects/Info.plist @@ -22,6 +22,13 @@ 1 LSRequiresIPhoneOS + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + + NSLocationWhenInUseUsageDescription + UILaunchStoryboardName LaunchScreen UIRequiredDeviceCapabilities @@ -31,18 +38,8 @@ UISupportedInterfaceOrientations UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight UIViewControllerBasedStatusBarAppearance - NSLocationWhenInUseUsageDescription - - NSAppTransportSecurity - - - NSAllowsArbitraryLoads - - diff --git a/ios/GLCanvas.m b/ios/GLCanvas.m index f3446bd..a082c39 100644 --- a/ios/GLCanvas.m +++ b/ios/GLCanvas.m @@ -284,6 +284,7 @@ RCT_NOT_IMPLEMENTED(-init) - (void)syncContentData { + RCT_PROFILE_BEGIN_EVENT(0, @"GLCanvas syncContentData", nil); NSMutableArray *contentData = [[NSMutableArray alloc] init]; int nb = [_nbContentTextures intValue]; for (int i = 0; i < nb; i++) { @@ -300,6 +301,9 @@ RCT_NOT_IMPLEMENTED(-init) contentData[i] = imgData; } _contentData = contentData; + _deferredRendering = true; + [self setNeedsDisplay]; + RCT_PROFILE_END_EVENT(0, @"gl", nil); } @@ -346,12 +350,7 @@ RCT_NOT_IMPLEMENTED(-init) BOOL needsDeferredRendering = _nbContentTextures > 0 && !_autoRedraw; if (needsDeferredRendering && !_deferredRendering) { - dispatch_async(dispatch_get_main_queue(), ^{ - if (!weakSelf) return; - _deferredRendering = true; - [self syncContentData]; - [weakSelf setNeedsDisplay]; - }); + [self performSelectorOnMainThread:@selector(syncContentData) withObject:nil waitUntilDone:NO]; } else { RCT_PROFILE_BEGIN_EVENT(0, @"GLCanvas render", nil); -- 2.26.2