react-native-video: iOS Fullscreen with Controls Crash

@ashnfb @cobarx

Current behavior

The following change crashes our current implementation on iOS: https://github.com/react-native-community/react-native-video/pull/1441/files#diff-42e8804735be64e84d6dd1fb103210a1R566 We display the video in full screen as soon as it is loaded. After updating this implementation crashes. A fix is not urgent for us, as we do not need the controls in non fullscreen mode on iOS. As a workaround we just disable the controls on iOS, which resolves the issue.

Reproduction steps

<Video source={this.props.source} resizeMode='contain' paused={false} repeat={false} controls={true} onLoad={() => this.player && this.player.presentFullscreenPlayer()} ref={this.handleRef} style={fullscreen} />

Additional info: We render the video in a react navigation dialog.

Expected behavior

It does not crash.

Platform

  • iOS
Exception thrown while executing UI block: Application tried to present modally an active controller <XXX.ReactNativeViewController: 0x7ff09b6182c0>.

__44-[RCTUIManager flushUIBlocksWithCompletion:]_block_invoke
    RCTUIManager.m:1112
__44-[RCTUIManager flushUIBlocksWithCompletion:]_block_invoke.461
__RCTExecuteOnMainQueue_block_invoke
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_main_queue_callback_4CF
__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
__CFRunLoopRun
CFRunLoopRunSpecific
GSEventRunModal
UIApplicationMain
main
start
0x0

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 12
  • Comments: 25 (3 by maintainers)

Commits related to this issue

Most upvoted comments

We have this issue too when setting fullscreen via presentFullscreenPlayer():

Simulator/Device (iOS)

  • Tested with local .mp4, remote .mp4 and remote .m3u8.

  • with controls set to true the simulator throws the following error:

Error setting property 'fullscreen' of RCTVideo with tag #3: Exception thrown while executing UI block: Application tried to present modally an active controller <UIViewController: 0x7fabe8c0fea0>.
  • with controls set to false the simulator does not throw and error but the video loses frame playback and gets stuck, forcing faster playback/catchup when you programmatically dismiss full screen mode via dismissFullscreenPlayer().

I’ve setup a test repo to reproduce and debug : https://github.com/4AllDigital/RNV-iOS

I’m happy to do any work/testing on this, but Im not an Objective-C developer and it seems that the issue is on that side, possibly around https://github.com/react-native-community/react-native-video/blob/master/ios/Video/RCTVideo.m#L1257, but I’d be guessing.

i have the same error on IOS, but when i set control={false},it works for me when can fix the issues?

I have this issue too, with react-native-video version 5.0.2. I can fullscreen player on iOS by clicking native control, but I get error if I’m calling presentFullscreenPlayer().

I’ve observed one thing here which allows playing video on fullscreen mode, I hope it will help others

use onFullscreenPlayerDidDismiss event with video like following

<Video 
    source={{
        uri: "your_video_url",
        headers: buildHeader()
      }}
     ref={(ref) => {
         this.player = ref
      }}
     repeat={false}
     onEnd={() => { console.log('onEnd') }}
     onFullscreenPlayerDidDismiss={() => { console.log('onFullscreenPlayerDidDismiss') }}
     onProgress={(evt) => {  }}
     onBuffer={this.onBuffer}
     onError={this.videoError}
     style={{
        position: 'absolute',
        top: 0,
        left: 0,
        bottom: 0,
        right: 0,
     }} 
/>

As you can see here I’m not doing anything here with this event but fullscreen working perfectly once I mentioned this event

Any update on this change? I am getting the same error. I am trying to make the video automatically go full screen if the user switches to landscape during playback.

Hi @joemewes, I’ve been away for 2 months, and haven’t been looking into react-native-video for some time. I will try and have a look in the next few weeks at this issue if I can find the time; I recall it being pretty ugly to fix because of legacy iOS APIs. Apologies that I can’t help more immediately.

I’ve observed one thing here which allows playing video on fullscreen mode, I hope it will help others

use onFullscreenPlayerDidDismiss event with video like following

<Video 
    source={{
        uri: "your_video_url",
        headers: buildHeader()
      }}
     ref={(ref) => {
         this.player = ref
      }}
     repeat={false}
     onEnd={() => { console.log('onEnd') }}
     onFullscreenPlayerDidDismiss={() => { console.log('onFullscreenPlayerDidDismiss') }}
     onProgress={(evt) => {  }}
     onBuffer={this.onBuffer}
     onError={this.videoError}
     style={{
        position: 'absolute',
        top: 0,
        left: 0,
        bottom: 0,
        right: 0,
     }} 
/>

As you can see here I’m not doing anything here with this event but fullscreen working perfectly once I mentioned this event

I can’t even see the log information here using the same code. It seems onFullscreenPlayerDidDismiss() on my ios simulator device does not work at all.

@ashnfb Sorry that it took so long. I’ve tried using your branch. I noticed that the video refuses the play in fullscreen now, if I set controls to true 😦

Sorry, haven’t had time to look at this yet. Will try my best to get to it quickly.

@jonas-arkulpa Yup. Should find some time next week 😃

@jonas-arkulpa @cobarx Try my master branch again --> https://github.com/nfb-onf/react-native-video, it includes fixes for the onXXX methods. I did not look at the controls issue.

iOS 11+ has much better methods for method-based entry into fullscreen mode. The code in the repo is much more complex than it needs to be because of legacy iOS support.

@jonas-arkulpa can you try this fix in my master branch before I do a pull request https://github.com/nfb-onf/react-native-video

cc @cobarx @fubar