From 6b1d97f052ff23761ad75df09318965f38c85ea4 Mon Sep 17 00:00:00 2001 From: Gazihan Alankus Date: Tue, 18 Aug 2020 15:50:57 +0300 Subject: [PATCH] Fixes crash in iOS 13.6 iPhone 11 --- ios/Video/RCTVideo.m | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/ios/Video/RCTVideo.m b/ios/Video/RCTVideo.m index fe319992bd..d1471aee8d 100644 --- a/ios/Video/RCTVideo.m +++ b/ios/Video/RCTVideo.m @@ -703,9 +703,15 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N if (!CGRectEqualToRect(oldRect, newRect)) { if (CGRectEqualToRect(newRect, [UIScreen mainScreen].bounds)) { - NSLog(@"in fullscreen"); - if (!_fullscreenPlayerPresented && _controls) { - _fullscreenPlayerPresented = YES; + bool shouldFire = !_fullscreenPlayerPresented; + + dispatch_async(dispatch_get_main_queue(), ^{ + if (shouldFire) { + _fullscreenPlayerPresented = YES; + } + }); + + if (shouldFire) { if(self.onVideoFullscreenPlayerWillPresent) { self.onVideoFullscreenPlayerWillPresent(@{@"target": self.reactTag}); } @@ -714,9 +720,15 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N } } } else { - NSLog(@"not fullscreen"); - if (_fullscreenPlayerPresented && _controls) { - _fullscreenPlayerPresented = NO; + bool shouldFire = _fullscreenPlayerPresented; + + dispatch_async(dispatch_get_main_queue(), ^{ + if (shouldFire) { + _fullscreenPlayerPresented = NO; + } + }); + + if (shouldFire) { if(self.onVideoFullscreenPlayerWillDismiss) { self.onVideoFullscreenPlayerWillDismiss(@{@"target": self.reactTag}); }