react-native-screens: `traverseForScrollView` crash with AVPlayer [iOS 17.2 BETA 1]

Description

iOS 17.2 beta 1 seems to crashing when using any implementation of AVPlayer with react-native-screens. Issue occurs only when we are using native controls

Some informations

In new iOS beta (17.2 beta 1) Apple add new UI element to AVPlayer hierarchy

Screenshot 2023-11-10 at 15 10 24

When we are navigating away from screen, react-native-screens calls traverseForScrollView and when we are reaching it, it’s throwing error that crash app

Error Message

*** -[__NSArray0 objectAtIndex:]: index 0 beyond bounds for empty array

Workaround

We can temporarily catch Screenshot 2023-11-10 at 15 21 40 with “try catch”, but it is not a very good solution because in the future we may miss some “important” error

I think we should wait for next iOS release - If this don’t get fixed the next step would be to detect if you are in AVPlayer and if so do not call the function

Steps to reproduce

To reproduce this issue we need to install xcode 15.1 beta 2 and iOS 17.2 sumulator.

Steps:

  1. Open provided example app
  2. Wait for video to load
  3. Navigate away from screen
  4. Application will crash

Snack or a link to a repository

https://github.com/abanobmikaeel/react-native-video-crash/

Screens version

3.27.0

React Native version

0.72.6

Platforms

iOS

JavaScript runtime

Hermes

Workflow

Expo bare workflow

Architecture

Paper (Old Architecture)

Build type

Debug mode

Device

iOS simulator

Device model

Any

Acknowledgements

Yes

About this issue

  • Original URL
  • State: closed
  • Created 8 months ago
  • Reactions: 4
  • Comments: 19 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Hi @KrzysztofMoch @udeyrishi @timharding! I’m happy to say that we’ve released new version of react-native-screens (3.29.0) which has this change included! 🥳

Check it out! If you find something wrong related to the newest version (this change is still buggy or doesn’t work for you) let us know 🎉

@tboba My react-native-screens version is “react-native-screens”: “^3.29.0” in my package.json. Have you recreated the crash on local environment?

@tboba Thanks for looking into this. I really appreciate your time. Following is the link to download my complete repo. https://drive.google.com/file/d/1FQLccz_Sd5jOLbr630eEkNU7YJKerERD/view?usp=drive_link

I have made this public. So you can directly download it. If you have any problems Please send me your email id. I will give you the access.

Thank you @tboba – we’ll give it a spin.

Hi @KrzysztofMoch, thanks for creating this issue! I confirm that this is reproducible. As we’ve discussed this bug at @software-mansion’s mini-conference, as you’ve said - I suggest to wait on the next iOS 17.2 betas, as the changes that Apple have made may be the cause here (somehow, in iOS 17.0.1 I cannot reproduce this).

Also, FYI: when I was debugging this issue I also saw that function traverseForScrollView is being called horrendously often, which also seems to be a bug (it looks that it is being called every frame of the video?) - I see potential points to improve there.