googlecast / CastVideos-ios

Reference iOS Sender w/ Framework API: CastVideos-ios application shows how to cast videos from an iOS device that is fully compliant with the Cast Design Checklist.
Apache License 2.0
192 stars 63 forks source link

Crash inside Cast SDK iOS if a video is too short and contains ads request at the same time. #127

Open soj opened 1 year ago

soj commented 1 year ago

Hello!

I found that if a video is short and contains ads request at the same time - it crashes inside Google Cast SDK for iOS in this component [GCKUIMediaController computeAdBlocks:]

I can provide sample app for this issue. I downloaded Cast sample app for iOS and just added one my method func makeNewItem() -> GCKMediaInformation which creates "problematic" item. This item contains short video - https://storage.googleapis.com/interactive-media-ads/media/blank-0.2-sec.m4v and VMAP ad tag url.

Steps to reproduce

  1. Run the app
  2. Connect to Chromecast and play any video from the list with "Play now" option
  3. I substitute the original item with the problematic item. In almost 100% of cases the app will crash with this crash stack below when the ad start on the Chromecast device
  4. I found that this crash is not occurred if the video file duration is longer

2022-12-02 08:44:28.630554+0600 CastVideos-swift[42068:611451] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ' -[NSArrayM insertObject:atIndex:]: object cannot be nil' *** First throw call stack: ( 0 CoreFoundation 0x0000000112d478cb exceptionPreprocess + 242 1 libobjc.A.dylib 0x000000010dc25ba3 objc_exception_throw + 48 2 CoreFoundation 0x0000000112dcf039 -[NSCFString characterAtIndex:].cold.1 + 0 3 CoreFoundation 0x0000000112dcc595 -[NSArrayM insertObject:atIndex:].cold.2 + 0 4 CoreFoundation 0x0000000112c31c18 -[NSArrayM insertObject:atIndex:] + 993 5 CastVideos-swift 0x0000000104da6cbb +[GCKUIMediaController computeAdBlocks:] + 1095 6 CastVideos-swift 0x0000000104da722d -[GCKUIMediaController remoteMediaClientDidUpdateProgress:] + 71 7 CastVideos-swift 0x0000000104e459b5 -[GCKRemoteMediaClient notifyDidUpdateProgress] + 218 8 CastVideos-swift 0x0000000104ebec62 -[GCKBWeakTimerTarget timerDidFire:] + 89 9 Foundation 0x0000000114385266 NSFireTimer + 67 10 CoreFoundation 0x0000000112ca7819 CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION + 20 11 CoreFoundation 0x0000000112ca7363 CFRunLoopDoTimer + 812 12 CoreFoundation 0x0000000112ca6ada CFRunLoopDoTimers + 243 13 CoreFoundation 0x0000000112ca12e4 __CFRunLoopRun + 2064 14 CoreFoundation 0x0000000112ca06f7 CFRunLoopRunSpecific + 560 15 GraphicsServices 0x0000000113a4728a GSEventRunModal + 139 16 UIKitCore 0x00000001255f362b -[UIApplication _run] + 994 17 UIKitCore 0x00000001255f8547 UIApplicationMain + 123 18 CastVideos-swift 0x0000000104d30fdf main + 63 Message from debugger: Terminated due to signal 6 19 dyld 0x000000010d9ac2bf start_sim + 10 20 ??? 0x0000000205638310 0x0 + 8680342288 )

Which version of the Cast SDK are you using? - I am using Cast SDK for iOS ver 4.7.0 (the latest one) On which version(s) of the OS (iOS, Android) do you observe the problem? - iOS 16.1 at least On which device type(s) such as phones, tablets or laptops (iPad, iPhone, etc.) do you observe the problem? iPhone, iPad Do you observe the problem when running on a physical device, or the simulator, or both? both

julianjohn commented 11 months ago

I am running into the very same issue. Cast SDK Version - 4.7.1 beta. Is there a possible fix for this?

maurovz commented 7 months ago

Replying for visibility as I have the same problem. As far as I know this crash persists as of latest version.

This bug report might be related: https://issuetracker.google.com/issues/260874571