From 6de06f1f540fc5449825fd1b750e721dfd408402 Mon Sep 17 00:00:00 2001 From: Zaid Daghestani Date: Mon, 1 Jul 2019 14:56:41 -0700 Subject: [PATCH 1/3] Remove calls to [super observe] to fix crash --- ios/Video/RCTVideo.m | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ios/Video/RCTVideo.m b/ios/Video/RCTVideo.m index 71bf82d855..33d6be42d9 100644 --- a/ios/Video/RCTVideo.m +++ b/ios/Video/RCTVideo.m @@ -595,8 +595,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N } return; - } else - return [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; + } } if([keyPath isEqualToString:readyForDisplayKeyPath] && [change objectForKey:NSKeyValueChangeNewKey] && self.onReadyForDisplay) { self.onReadyForDisplay(@{@"target": self.reactTag}); @@ -713,8 +712,6 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N @"target": self.reactTag}); } } - } else { - [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; } } From 68761793fd9ee2851d14d5107ea3b73654140412 Mon Sep 17 00:00:00 2001 From: Zaid Daghestani Date: Tue, 2 Jul 2019 11:43:22 -0700 Subject: [PATCH 2/3] Add #1646 to changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8668a91585..74c0c66a51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ ## Changelog +### Version 4.4.3 +* Fix iOS stressed mount/unmount crash [#1646](https://github.com/react-native-community/react-native-video/pull/1646) + ### Version 4.4.2 * Change compileOnly to implementation on gradle (for newer gradle versions and react-native 0.59 support) [#1592](https://github.com/react-native-community/react-native-video/pull/1592) * Replaced RCTBubblingEventBlock events by RCTDirectEventBlock to avoid event name collisions [#1625](https://github.com/react-native-community/react-native-video/pull/1625) From 4a3ea937394f43a1e3bce75ab5dc0576cc6cfa5d Mon Sep 17 00:00:00 2001 From: Zaid Daghestani Date: Tue, 2 Jul 2019 13:35:36 -0700 Subject: [PATCH 3/3] bring back super KVO with selector check --- ios/Video/RCTVideo.m | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/ios/Video/RCTVideo.m b/ios/Video/RCTVideo.m index 33d6be42d9..654deb2a81 100644 --- a/ios/Video/RCTVideo.m +++ b/ios/Video/RCTVideo.m @@ -578,25 +578,7 @@ - (void)dvAssetLoaderDelegate:(DVAssetLoaderDelegate *)loaderDelegate - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { - // when controls==true, this is a hack to reset the rootview when rotation happens in fullscreen - if (object == _playerViewController.contentOverlayView) { - if ([keyPath isEqualToString:@"frame"]) { - - CGRect oldRect = [change[NSKeyValueChangeOldKey] CGRectValue]; - CGRect newRect = [change[NSKeyValueChangeNewKey] CGRectValue]; - - if (!CGRectEqualToRect(oldRect, newRect)) { - if (CGRectEqualToRect(newRect, [UIScreen mainScreen].bounds)) { - NSLog(@"in fullscreen"); - } else NSLog(@"not fullscreen"); - - [self.reactViewController.view setFrame:[UIScreen mainScreen].bounds]; - [self.reactViewController.view setNeedsLayout]; - } - - return; - } - } + if([keyPath isEqualToString:readyForDisplayKeyPath] && [change objectForKey:NSKeyValueChangeNewKey] && self.onReadyForDisplay) { self.onReadyForDisplay(@{@"target": self.reactTag}); return; @@ -712,6 +694,26 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N @"target": self.reactTag}); } } + } else if (object == _playerViewController.contentOverlayView) { + // when controls==true, this is a hack to reset the rootview when rotation happens in fullscreen + if ([keyPath isEqualToString:@"frame"]) { + + CGRect oldRect = [change[NSKeyValueChangeOldKey] CGRectValue]; + CGRect newRect = [change[NSKeyValueChangeNewKey] CGRectValue]; + + if (!CGRectEqualToRect(oldRect, newRect)) { + if (CGRectEqualToRect(newRect, [UIScreen mainScreen].bounds)) { + NSLog(@"in fullscreen"); + } else NSLog(@"not fullscreen"); + + [self.reactViewController.view setFrame:[UIScreen mainScreen].bounds]; + [self.reactViewController.view setNeedsLayout]; + } + + return; + } + } else if ([super respondsToSelector:@selector(observeValueForKeyPath:ofObject:change:context:)]) { + [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; } }