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
194 stars 62 forks source link

Google Cast iOS SDK crashes when playing SSAI streams and receiver send ad blocks #131

Open rajeshbeats opened 1 year ago

rajeshbeats commented 1 year ago

We have noticed Google Cast iOS SDK crashes when we try to cast SSAI (Server-Side Ad Insertion) videos and the receiver sends ad blocks events back to the app. The crash is caused by an exception in the -[__NSArrayM insertObject:atIndex:] method of the Core Foundation framework inside Google cast iOS SDK.

libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
terminating with uncaught exception of type NSException

Steps to reproduce:

Launch the app and connect to a receiver. Play an SSAI video on the receiver. Wait for an ad to play and the receiver to send ad blocks back to the app. Observe that the app crashes.

Expected behavior:

The SDK should handle ad blocks sent by the receiver without crashing.

Actual behavior:

The SDK crashes when the receiver sends ad blocks back to the app.

Additional information on environment

Device : iPhone 12 OS : 16.2 Xcode version: 14.1

Here is the stack trace from crash report

Last Exception Backtrace:
0   CoreFoundation                  0x199cb2708 __exceptionPreprocess + 220 (NSException.m:199)
1   libobjc.A.dylib                 0x1ae7bc7a8 objc_exception_throw + 60 (objc-exception.mm:565)
2   CoreFoundation                  0x199d249c8 _CFThrowFormattedException + 116 (CFObject.m:2015)
3   CoreFoundation                  0x199d21f4c -[__NSArrayM insertObject:atIndex:].cold.1 + 52 (NSArrayM.m:157)
4   CoreFoundation                  0x199b8bb5c -[__NSArrayM insertObject:atIndex:] + 1020 (NSArrayM.m:157)
5   GoogleCast                      0x107e81270 +[GCKUIMediaController computeAdBlocks:] + 832
6   GoogleCast                      0x107e817ec -[GCKUIMediaController remoteMediaClientDidUpdateProgress:] + 76
7   GoogleCast                      0x107f16480 -[GCKRemoteMediaClient notifyDidUpdateProgress] + 192
8   GoogleCast                      0x107f5ed4c -[GCKBWeakTimerTarget timerDidFire:] + 88
9   Foundation                      0x19b087438 __NSFireTimer + 104 (NSTimer.m:280)
10  CoreFoundation                  0x199c2d1d4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 32 (CFRunLoop.c:1807)
11  CoreFoundation                  0x199c2cdd0 __CFRunLoopDoTimer + 1076 (CFRunLoop.c:2415)
12  CoreFoundation                  0x199c2c220 __CFRunLoopDoTimers + 328 (CFRunLoop.c:2575)
13  CoreFoundation                  0x199c25f8c __CFRunLoopRun + 1872 (CFRunLoop.c:3080)
14  CoreFoundation                  0x199c25308 CFRunLoopRunSpecific + 600 (CFRunLoop.c:3242)
15  GraphicsServices                0x1b12a8734 GSEventRunModal + 164 (GSEvent.c:2259)
16  UIKitCore                       0x19c6a375c -[UIApplication _run] + 1072 (UIApplication.m:3269)
17  UIKitCore                       0x19c6a8fcc UIApplicationMain + 168 (UIApplication.m:4740)
18  MyApp_iOS                       0x104e9cc14 main + 176

We observed below warning appears before the crash. -[GCKUICastSliderAdBlock initWithAdBlockPosition:adBlockDuration:watched:expanded:] - adBlockPosition should be within the range [0:1]

Also, Our iOS app doesnt have implementation of GCKUIMediaController or any Ad Breaks (such as GCKAdBreakClipInfoBuilder)

darrennolan commented 1 year ago

A note, we have sender applications on both Android and Web that don't encounter this issue with the setup of ads on streams, this only seems to affect iOS sender applications.

julianjohn commented 10 months ago

@rajeshbeats & @darrennolan I am also running into this issue. Were you guys able to fix this issue?

darrennolan commented 10 months ago

@julianjohn - never really resolved. We even reached out to our partnerships people. For us, the specific issue was ads of very short length, < 5s. I think we had 3s bumpers added in that worked as ads, and that caused the issue. When those bumpers were removed (before further testing from us/google) - the issue went away and no one was able to investigate further.

Hope that helps you a little.

julianjohn commented 10 months ago

Thanks very much, @darrennolan. This helps. In our case, it is a ~1 min video.

alarochelle commented 6 months ago

Also running into this issue. Not happening on Web or Android, only iOS. Happens with pretty long content (~20mins) and ads are minimum 5-15s. Always happens whenever the content reaches the end or starts.