Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
vidangelci opened this issue Oct 4, 2023 · 10 comments
Open

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

vidangelci opened this issue Oct 4, 2023 · 10 comments
Assignees
Labels
bug Something isn't working

Comments

@vidangelci
Copy link

vidangelci commented Oct 4, 2023

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.

@tvanlaerhoven tvanlaerhoven added the bug Something isn't working label Oct 6, 2023
@wvanhaevre
Copy link
Collaborator

Thanks for reporting. I will investigate.

@webnard
Copy link
Contributor

webnard commented Oct 6, 2023

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
Copy link
Collaborator

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
Copy link
Collaborator

@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
Copy link
Contributor

webnard commented Oct 11, 2023

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

@wvanhaevre
Copy link
Collaborator

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

@wvanhaevre
Copy link
Collaborator

@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
Copy link
Contributor

webnard commented Oct 17, 2023

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

@wvanhaevre
Copy link
Collaborator

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

  • use the API's player.ads.scheduledAdBreaks() method.
  • mark ads that have played as 'done' using some state
  • listen to SEEKED event on the player: player.addEventListener(PlayerEventType.SEEKED, ...)
  • if a seek crosses an adBreak startTime, keep the currentTime, do a seek to the ad startTime, seek back to the previously stored currentTime.

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

@webnard
Copy link
Contributor

webnard commented Oct 17, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants