From e43409fc834e39900b0cc979926f0ebf10151c05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Sat, 21 Nov 2015 15:29:57 +0100 Subject: [PATCH] Fix crash when swap some GLCanvas props probable race condition fixed, syncData is not executed during the draw phase --- ios/GLCanvas.m | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ios/GLCanvas.m b/ios/GLCanvas.m index a19c97d..a06e967 100644 --- a/ios/GLCanvas.m +++ b/ios/GLCanvas.m @@ -49,6 +49,8 @@ NSString* srcResource (id res) NSTimer *animationTimer; int _lastCaptureId; + + BOOL _needSync; } - (instancetype)initWithBridge:(RCTBridge *)bridge @@ -153,7 +155,8 @@ RCT_NOT_IMPLEMENTED(-init) - (void)requestSyncData { - [self syncData]; + _needSync = true; + [self setNeedsDisplay]; } - (void)syncData @@ -191,6 +194,7 @@ RCT_NOT_IMPLEMENTED(-init) id value = [data.uniforms objectForKey:uniformName]; GLenum type = [uniformTypes[uniformName] intValue]; + if (type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE) { uniforms[uniformName] = [NSNumber numberWithInt:units++]; if ([value isEqual:[NSNull null]]) { @@ -269,8 +273,6 @@ RCT_NOT_IMPLEMENTED(-init) _renderData = traverseTree(_data); _images = images; - - [self setNeedsDisplay]; } } @@ -296,6 +298,10 @@ RCT_NOT_IMPLEMENTED(-init) - (void)drawRect:(CGRect)rect { + if (_needSync) { + _needSync = false; + [self syncData]; + } self.layer.opaque = _opaque; [self syncEventsThrough]; __weak GLCanvas *weakSelf = self; -- 2.26.2