[iOS] Crash with IMAAdViewController occurred : UIViewControllerHierarchyInconsistency

845 views
Skip to first unread message

Alexis Vautier

unread,
Sep 2, 2021, 2:03:31 PM9/2/21
to Interactive Media Ads SDK
Hello everyone. I am working on a application, with a Video player. (JWPlayer).
I integrated a custom Picture on Picture and it performed well : I am able to move the Player from a View to the PiP. 

I integrated GoogleIMA SDK and... it does not properly work anymore. The app will crash as soon as I try to move the Player from a View o the PiP. But, when the preroll is over, it works as expected. Here is the stack trace : 

Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'child view controller:<IMAAdViewController: 0x7fa542343260> should have parent view controller:<VideoplayerWrapperLib.PIPViewController: 0x7fa53ff38ce0> but actual parent is:<VideoplayerWrapper.ViewController: 0x7fa542007060>'

It seems that this issue is not unknown : 

https://groups.google.com/g/ima-sdk/c/Z6icBTi59Ms

https://groups.google.com/g/ima-sdk/c/NyHuNuE7QDI

Thanks for your help 😀 

Best regards,

Alexis

IMA SDK

unread,
Sep 3, 2021, 2:38:39 AM9/3/21
to alexis....@webedia-group.com, ima...@googlegroups.com
Hi Alexis,

Thank you for reaching out to us.

With regard to your concern, it is expected behavior that IMA doesn't explicitly support custom full-screen solutions like this that involve juggling around the video views and view controllers. That said, the publisher likely can accomplish what they want by detaching, moving, and reattaching a parent of the entire ad display container view/controller that contains the video player and AdUI, so that all of the components related to IMA move together.

Regards,
Google Logo
Teejay Wennie Pimentel
IMA SDK Team
 


ref:_00D1U1174p._5004Q2Ml4K5:ref

Alexis Vautier

unread,
Sep 3, 2021, 3:01:29 AM9/3/21
to Interactive Media Ads SDK
First, thanks a lot for your support. 

Capture d’écran 2021-09-03 à 08.54.43.png

When I inspect the layer, I see an IMAAdViewController, near the JWPWebview. I could contact the JWPlayer support team, but maybe I could also fix the issue without waiting a fix on their side. 
Do you thing I could try to remove this IMAAdViewController, store it elsewhere and re-insert it when I will need it ? 

Thanks
Best regards,
Alexis 

IMA SDK

unread,
Sep 3, 2021, 1:14:50 PM9/3/21
to alexis....@webedia-group.com, ima...@googlegroups.com
Hi Alexis,

Thank you for reaching back out to us. In looking over your screenshot. I would in general agree with you. That taking the component you want to move or change. Holding it somewhere or attaching it to another component that is maybe hidden or at least not in view but still in hierarchy. Then attach it where you would like. But the only question I would have is do you remove the IMAAdViewController, or would you take it further up like JWAVContainer? So as to get everything.

Regards,
Google Logo
William Pescherine
IMA SDK Team
 


ref:_00D1U1174p._5004Q2Ml4K5:ref

Alexis Vautier

unread,
Sep 6, 2021, 4:43:20 AM9/6/21
to Interactive Media Ads SDK

Hello 

Thanks for your answer
My goal is to move the full Player, the JWAVContainer and IMAAdViewController in an other container. 

Here what I currently perform : 

extension UIView {

    func findViewController() -> UIViewController? {

        if let nextResponder = self.next as? UIViewController {

            return nextResponder

        } else if let nextResponder = self.next as? UIView {

            return nextResponder.findViewController()

        } else {

            return nil

        }

    }

}

Then, when I want to move the Player : 

if let playerView = JWPlayerManager.shared.getPlayerView() {

                if let subviews = playerView.subviews.first?.subviews,

                   subviews.count > 1,

                   let imaViewController = subviews[1].findViewController() {

                    let imaView = subviews[1]

                    imaViewController.willMove(toParent: parentViewController)

                    playerView.removeFromSuperview()

                   parentViewController.addChild(imaViewController)

                    container.addSubview(playerView)

                    playerView.constraintToSuperview(superView: container)

                   imaViewController.didMove(toParent: parentViewController)


Sorry for all this code. I hope it won't look too messy. So, I can properly migrate the IMAAdViewController from a view to an other... but I lose the controls ! There is an other controller in the view, a IMAWebUIViewController, according the the following screenshot : 

Capture d’écran 2021-09-06 à 10.37.32.png


I am still trying to migrate the two viewControllers at the same time. If you have any clues 😀 

Maybe my code will also help people. 

Best regards,

Alexis

IMA SDK

unread,
Sep 6, 2021, 10:07:36 PM9/6/21
to alexis....@webedia-group.com, ima...@googlegroups.com

Hi Alexis,

 

Thank you for your response.

 

Could you please confirm if you have followed this guide for supporting PiP in your application that is using the IMA SDK? Would you also be able to share with us the sample project implementation you are currently working on? Upon submitting, I will raise it to the rest of the team to have it check and further investigate, and possibly advise how to achieve your goal.

You can share the requested sample via "reply to author" or send it directly to our testing alias imate...@gmail.com

Regards,

Google Logo
Michael Angelo Legaspi
IMA SDK Team
 


ref:_00D1U1174p._5004Q2Ml4K5:ref

Alexis Vautier

unread,
Sep 7, 2021, 8:52:54 AM9/7/21
to Interactive Media Ads SDK
Hello

I am not currently using AVPlayer, but JWPlayer. So, I can't use the native PiP. I think native PiP could be better, but JWPlayer does not support it properly yet. There are also more requirements, because we are targeting more versions of iOS (below iOS 14) and the PiP is not available on iPhone. 

But moving the Player view (and the Ad Container) is like moving from a classic view to an other.

I have the same issue when I want to "embed" the Player in a view controller, then open an other view controller modally, using the same Player's instance. I want to keep the progression, the sound, keep it fluide. 

Thanks for your support
Alexis 

IMA SDK

unread,
Sep 7, 2021, 1:52:46 PM9/7/21
to alexis....@webedia-group.com, ima...@googlegroups.com
Hi Alexis,

Thank you for the updated information. We will be needing to see a simple sample of this implementation as it is something that appears to be outside of what we have shown. If you can share with us via the "Reply to Author" button. We will be able to bring this to our team to have them look more into this and see what they have to say.

Regards,
Google Logo
William Pescherine
IMA SDK Team
 


ref:_00D1U1174p._5004Q2Ml4K5:ref

Alexis VAUTIER

unread,
Sep 8, 2021, 4:15:14 AM9/8/21
to Interactive Media Ads SDK
Hello 
Thanks again for your support.

Due to the fact I am using a licence key using JWPlayer, I sent you a sample project using your mail. 
I can't send you the full projet, but this is the same behavior. 

I also specify more instructions in the mail. 
Can you confirm you received it ? 

Thanks a lot
Best regards 

Alexis 

Alexis VAUTIER

unread,
Sep 8, 2021, 10:06:46 AM9/8/21
to Interactive Media Ads SDK
Hello again. I would like to know : is there a way to get the "clickThroughUrl" and "skipoffset" ? Maybe we could use our own controls layer, but we don't have this two informations.
- clickThroughUrl is used to redirect the user when he taps on "Know More"
- skipOffset is used to know when a user is able to skip an ad 

Thanks a lot
Best regards

Alexis

IMA SDK

unread,
Sep 8, 2021, 1:49:22 PM9/8/21
to alexis....@webedia-group.com, ima...@googlegroups.com
Hi Alexis,

Thank you for all the information. I will pass along some information that we have received previously from our team. Which I believe was passed on to you.
 
The publisher likely can accomplish what they want by detaching, moving, and reattaching a parent of the entire ad display container view/controller that contains the video player and AdUI, so that all of the components related to IMA move together.
 
With that also being said, in looking over our documents I do not see any way to get the deeplink. As it looks like Apple will not allow it. But In android you are able to get it through getContentURL(). As for the skip functionally, you should be able to create a similar effect through various ways to manipulate the UI element.


Regards,
Google Logo
William Pescherine
IMA SDK Team
 


ref:_00D1U1174p._5004Q2Ml4K5:ref

Alexis VAUTIER

unread,
Sep 9, 2021, 4:24:53 AM9/9/21
to Interactive Media Ads SDK
Hello
Thanks for your support
Do you know if there is a way to get the SkipOffset value using a AdId or a CreativeId ? 

We may be able to use an other way, but we still need to retrieve the SkipOffset value.
Thanks
Best regards,
Alexis

IMA SDK

unread,
Sep 9, 2021, 6:04:13 AM9/9/21
to alexis....@webedia-group.com, ima...@googlegroups.com

Hi Alexis,

 

Thank you for responding back to us. I believe you are referring to skipTimeOffset functionality. This feature will let you know the number of seconds of playback before the ad becomes skippable. It will return a value of -1 for non skippable ads or if this is unavailable.

Regards,

Google Logo
Michael Angelo Legaspi
IMA SDK Team
 


ref:_00D1U1174p._5004Q2Ml4K5:ref
Reply all
Reply to author
Forward
0 new messages