Skip to content

Commit d7cba6d

Browse files
authored
fix(iOS): Don't include AVPlayerView in traverseForScrollView method (software-mansion#1969)
## Description Currently, in iOS 17.2 Beta 1-2 there's a bug that causes application to crash after going to the second screen with the video player that contains controls. This PR fixes this issue. Closes software-mansion#1967. ## Changes - Added an if statement that returns if view is type of `AVPlayerView`, as we don't want to signal it about decelerating (sadly, this header file is not in UIKit's public API 😕. ## Screenshots / GIFs ### Before https://github.com/software-mansion/react-native-screens/assets/23281839/6d040536-45fb-41ea-ad8a-1c86352bf199 ### After https://github.com/software-mansion/react-native-screens/assets/23281839/6da618e4-2bf9-47fb-be9f-e73ae560f081 ## Test code and steps to reproduce You can test this change on the repro, attached in the original issue: https://github.com/abanobmikaeel/react-native-video-crash/ ## Checklist - [X] Ensured that CI passes
1 parent 4224c7c commit d7cba6d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

ios/RNSScreen.mm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,6 +1423,15 @@ - (void)traverseForScrollView:(UIView *)view
14231423
// we don't want to send `scrollViewDidEndDecelerating` event to JS before the JS thread is ready
14241424
return;
14251425
}
1426+
1427+
if ([NSStringFromClass([view class]) isEqualToString:@"AVPlayerView"]) {
1428+
// Traversing through AVPlayerView is an uncommon edge case that causes the disappearing screen
1429+
// to an excessive traversal through all video player elements
1430+
// (e.g., for react-native-video, this includes all controls and additional video views).
1431+
// Thus, we want to avoid unnecessary traversals through these views.
1432+
return;
1433+
}
1434+
14261435
if ([view isKindOfClass:[UIScrollView class]] &&
14271436
([[(UIScrollView *)view delegate] respondsToSelector:@selector(scrollViewDidEndDecelerating:)])) {
14281437
[[(UIScrollView *)view delegate] scrollViewDidEndDecelerating:(id)view];

0 commit comments

Comments
 (0)