Skip to content
This repository has been archived by the owner on Jan 1, 2020. It is now read-only.

Commit

Permalink
Fix crash when swap some GLCanvas props
Browse files Browse the repository at this point in the history
probable race condition fixed, syncData is not executed during the draw phase
  • Loading branch information
gre committed Nov 21, 2015
1 parent 1e2457e commit e43409f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions ios/GLCanvas.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ @implementation GLCanvas
NSTimer *animationTimer;

int _lastCaptureId;

BOOL _needSync;
}

- (instancetype)initWithBridge:(RCTBridge *)bridge
Expand Down Expand Up @@ -153,7 +155,8 @@ - (void) syncEventsThrough

- (void)requestSyncData
{
[self syncData];
_needSync = true;
[self setNeedsDisplay];
}

- (void)syncData
Expand Down Expand Up @@ -191,6 +194,7 @@ - (void)syncData
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]]) {
Expand Down Expand Up @@ -269,8 +273,6 @@ - (void)syncData

_renderData = traverseTree(_data);
_images = images;

[self setNeedsDisplay];
}
}

Expand All @@ -296,6 +298,10 @@ - (void)syncContentTextures

- (void)drawRect:(CGRect)rect
{
if (_needSync) {
_needSync = false;
[self syncData];
}
self.layer.opaque = _opaque;
[self syncEventsThrough];
__weak GLCanvas *weakSelf = self;
Expand Down

0 comments on commit e43409f

Please sign in to comment.