react-native-video: [iOS] App crash when rendering

Tested this in the example and getting the same result there as in my app, react-native 0.37.0, react-native-video 0.9.0. App crashes when trying to load a local file as the source.

2016-11-14 22:32:56.362 VideoPlayer[36810:5128476] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000010588334b __exceptionPreprocess + 171
	1   libobjc.A.dylib                     0x000000010439a21e objc_exception_throw + 48
	2   CoreFoundation                      0x00000001058ec265 +[NSException raise:format:] + 197
	3   Foundation                          0x0000000103e8d4c1 -[NSURL(NSURL) initFileURLWithPath:] + 131
	4   VideoPlayer                         0x0000000103b7b620 -[RCTVideo playerItemForSource:] + 624
	5   VideoPlayer                         0x0000000103b7abd5 -[RCTVideo setSrc:] + 117
	6   VideoPlayer                         0x0000000103b21908 __49-[RCTComponentData propBlockForKey:inDictionary:]_block_invoke.227 + 328
	7   VideoPlayer                         0x0000000103b22250 __49-[RCTComponentData propBlockForKey:inDictionary:]_block_invoke.259 + 720
	8   VideoPlayer                         0x0000000103b225c8 __49-[RCTComponentData propBlockForKey:inDictionary:]_block_invoke_2.272 + 40
	9   VideoPlayer                         0x0000000103ababd6 RCTPerformBlockWithLogFunction + 374
	10  VideoPlayer                         0x0000000103abad1d RCTPerformBlockWithLogPrefix + 221
	11  VideoPlayer                         0x0000000103b2252d __49-[RCTComponentData propBlockForKey:inDictionary:]_block_invoke.267 + 445
	12  VideoPlayer                         0x0000000103b22a25 __37-[RCTComponentData setProps:forView:]_block_invoke + 181
	13  CoreFoundation                      0x000000010580a9d6 __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 102
	14  CoreFoundation                      0x000000010580a8da -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 202
	15  VideoPlayer                         0x0000000103b2288f -[RCTComponentData setProps:forView:] + 223
	16  VideoPlayer                         0x0000000103b0aab2 __50-[RCTUIManager createView:viewName:rootTag:props:]_block_invoke + 162
	17  libdispatch.dylib                   0x0000000109850980 _dispatch_call_block_and_release + 12
	18  libdispatch.dylib                   0x000000010987a0cd _dispatch_client_callout + 8
	19  libdispatch.dylib                   0x000000010985a8d6 _dispatch_main_queue_callback_4CF + 406
	20  CoreFoundation                      0x00000001058474f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
	21  CoreFoundation                      0x000000010580cf8d __CFRunLoopRun + 2205
	22  CoreFoundation                      0x000000010580c494 CFRunLoopRunSpecific + 420
	23  GraphicsServices                    0x000000010b172a6f GSEventRunModal + 161
	24  UIKit                               0x0000000107eef964 UIApplicationMain + 159
	25  VideoPlayer                         0x0000000103a2a8cf main + 111
	26  libdyld.dylib                       0x00000001098c668d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

image

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 1
  • Comments: 21 (4 by maintainers)

Most upvoted comments

From what I experience, the same type of exception (observers not correctly removed before deallocation) is appearing in two different cases:

A) for observers of the AVPlayerItem class B) for observers of the AVPlayerLayer class

For case A, I tried manually applying the changes from the commit mentioned by @tasarsu and it did work. Seems that the code from the current npm package version is prior to that commit.

For case B, setting controls={true} in the props of the <Video /> element seems to avoid rendering the AVPlayerLayer entirely, so the exception never appears.

Just my two cents on the matter.

Just gave this another go now and strange enough, it works fine.

I was using an external url, went ahead and swapped it for require('path to video'), and saw my video playing fine.

Try relaunching Xcode / react package manager / simulator after adding the video file to your project. Those are the only things I can think I’ve done since opening the issue that would affect this.