THEOplayer / react-native-theoplayer

A React Native THEOplayerView component
https://theoplayer.github.io/react-native-theoplayer/
MIT License
56 stars 21 forks source link

react-native-theoplayer not properly handling IMA ads on iOS #207

Open vidangelci opened 9 months ago

vidangelci commented 9 months ago

We have upgraded from the 1.x.x branch to the 2.x.x branch and made all the configuration changes, with the goal of being able to use version 5.x.x of the THEO sdk. For Android, everything works great. For iOS, however, this upgrade has created a couple of issues for iOS devices when trying to play IMA ads. Here are the issues:

1) When seeking over a scheduled ad, the IMA plugin does not play the adbreak that was scheduled. It does play the adbreak on Android (and used to when using the 1.x.x branch with THEO-ios sdk 4.11). This problem does not occur when the scheduled ad is reached linearly (i.e. when it encounters it during normal playback) ... only when seeking past the adbreak.

2) After having played an ad, or after seeking past the place where a scheduled as is (even if it doesn't play because of the above issue), destroying the player crashes the app. Again, this does not happen on Android, or on the 1.x.x branch (using sdk 4.11).

To help troubleshoot, we have taken the sample react-native app and modified it to easily reproduce. it can be found at https://content.vidangel.com/theo-ad-test.zip -- after building, playing it on iOS should:

1) play all ads fine straight through 2) fail to play ads if you scrub past the adbreaks 3) crash the app if you play through an ad or scrub past an ad and then use the "toggle off" button (which destroys the player)

If this would be better submitted as a helpdesk ticket, let us know. We're hoping there's something that can be addressed to resolve this, though.

wvanhaevre commented 9 months ago

Thanks for reporting. I will investigate.

webnard commented 9 months ago

This happens on version 3.0.0 as well. Here's a paste of the callstack from the crashing thread:

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libobjc.A.dylib                        0x1800362a8 object_isClass + 16
1   Foundation                             0x180d45370 KVO_IS_RETAINING_ALL_OBSERVERS_OF_THIS_OBJECT_IF_IT_CRASHES_AN_OBSERVER_WAS_OVERRELEASED_OR_SMASHED + 72
2   Foundation                             0x180d41cd4 NSKeyValueWillChangeWithPerThreadPendingNotifications + 284
3   AVFCore                                0x1a974721c __avplayeritem_fpItemNotificationCallback_block_invoke_19 + 52
4   libdispatch.dylib                      0x1801424f4 _dispatch_call_block_and_release + 24
5   libdispatch.dylib                      0x180143d3c _dispatch_client_callout + 16
6   libdispatch.dylib                      0x180152b24 _dispatch_main_queue_drain + 1272
7   libdispatch.dylib                      0x18015261c _dispatch_main_queue_callback_4CF + 40
8   CoreFoundation                         0x1803c61b4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
9   CoreFoundation                         0x1803c08cc __CFRunLoopRun + 1936
10  CoreFoundation                         0x1803bfd28 CFRunLoopRunSpecific + 572
11  GraphicsServices                       0x18986ebc0 GSEventRunModal + 160
12  UIKitCore                              0x118e2bfdc -[UIApplication _run] + 868
13  UIKitCore                              0x118e2fc54 UIApplicationMain + 124
14  AwesomeProject                         0x102eadf90 main + 100 (main.m:8)
15  dyld_sim                               0x105c3d558 start_sim + 20
16  dyld                                   0x1055e6058 start + 2224
wvanhaevre commented 9 months ago

Yes indeed. We see this crash log after a IMA Ad has played and the player is destroyed/unmounted. We are now re-evaluating our GoogleIMA integration in relation to the KVO on the avPlayerItem. Once we have a fix for our native iOS SDK we'll report back.

wvanhaevre commented 9 months ago

@vidangelci , @webnard , we've made a change on our native iOS SDK that sits underneath the RN SDK. This should solve the crash that happens after destroying the player once an IMA ad finishes playing. A pod update on your RN application, to bring the iOS SDK dependency to THEOplayerSDK-core v6.1.1 should fix the issue.

webnard commented 9 months ago

@wvanhaevre I can confirm this fixes the crashing. Issue 1 is still happening, but we're not seeing any more crashes. Thank you!

wvanhaevre commented 9 months ago

I'll check on the status of 'issue 1'

wvanhaevre commented 9 months ago

@webnard , I checked our IMA setup and it seems that this snapback behaviour on iOS is only supported for DAI and for VMAP based IMA. For a simple VAST file, scheduled on our player or passed as AdDescription in the SourceDescription, that mechanism is not active.

On iOS this sample has midrolls at 00:00:15 which will play if you skip over them. But for a simple VAST based AdDescription, our iOS SDK does not take into account the schedule when skipping the defined timeOffsets. This is something we could put on the roadmap.

webnard commented 9 months ago

@wvanhaevre Thank you. The snapback issue seems to be a regression. We're not seeing the problem on previous versions.

wvanhaevre commented 9 months ago

When you refer to previous versions where the snapback was working, is that 1.x.x versions of the react-native-theoplayer package? Since 2.x.x we've moved for iOS from a web-based SDK to a fully native implementation of the features. Meaning that also the IMA functionality was completely rewritten. It could be we had this functionality in that web-based setup but did not yet implement it natively.

Maybe a suggestion for a workaround possible using the API

I will check if we can put this on our roadmap in the meantime.

webnard commented 9 months ago

When you refer to previous versions where the snapback was working, is that 1.x.x versions of the react-native-theoplayer package?

Yes, specifically it looks like we were using 1.8.1. Thank you for the advice on a workaround—we can work with that for the time being.