Crash with IMAAdViewController occurred : UIViewControllerHierarchyInconsistency

262 views
Skip to first unread message

Gaurav Purohit

unread,
Apr 8, 2022, 11:47:58 AM4/8/22
to Interactive Media Ads SDK
Hi,

We are getting crashes sometime in our app. Please find the error as below:

Fatal Exception: UIViewControllerHierarchyInconsistency 
child view controller:<IMAAdViewController: 0x10e66fe60> should have parent view controller:<HomePageSectionFrontController: 0x104106600> but actual parent is:<RootViewController: 0x1040cd400>

Here is crash report:

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Triggered by Thread:  0

Last Exception Backtrace:
0   CoreFoundation                    0x1813b10fc __exceptionPreprocess + 220 (NSException.m:200)
1   libobjc.A.dylib                   0x199bebd64 objc_exception_throw + 60 (objc-exception.mm:565)
2   CoreFoundation                    0x181408230 +[NSException raise:format:] + 112 (NSException.m:156)
3   UIKitCore                         0x183ca1f84 -[UIView(Hierarchy) _associatedViewControllerForwardsAppearanceCallbacks:performHierarchyCheck:isRoot:] + 288 (UIView.m:11825)
4   UIKitCore                         0x183bd3384 -[UIView(Hierarchy) _willMoveToWindow:withAncestorView:] + 248 (UIView.m:12024)
5   UIKitCore                         0x183949ae4 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 436 (UIView.m:16583)
6   GoogleInteractiveMediaAds         0x104c541dc -[IMAAdDisplayContainer setAdViewController:] + 448
7   GoogleInteractiveMediaAds         0x104c45ef0 -[IMAAdsManager handleMessageContentPauseRequested:] + 180
8   CoreFoundation                    0x181342f88 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 28 (CFNotificationCenter.c:652)
9   CoreFoundation                    0x1813dec3c ___CFXRegistrationPost_block_invoke + 52 (CFNotificationCenter.c:173)
10  CoreFoundation                    0x1813b1ff4 _CFXRegistrationPost + 456 (CFNotificationCenter.c:199)
11  CoreFoundation                    0x181358df4 _CFXNotificationPost + 716 (CFNotificationCenter.c:1147)
12  Foundation                        0x182b55f68 -[NSNotificationCenter postNotificationName:object:userInfo:] + 96 (NSNotification.m:560)
13  GoogleInteractiveMediaAds         0x104c674b8 -[IMAJavaScriptSession didReceiveMessage:] + 324
14  GoogleInteractiveMediaAds         0x104c668bc -[IMABaseDispatcher processNewMessage:] + 260
15  GoogleInteractiveMediaAds         0x104c667a8 -[IMABaseDispatcher processNewMessageWithChannelName:data:] + 68
16  GoogleInteractiveMediaAds         0x104c660c8 -[IMAWebViewDispatcher processNewMessageWithChannelName:data:] + 100
17  GoogleInteractiveMediaAds         0x104c3fb14 -[IMAJavaScriptIosBridge webView:didReceiveMessage:] + 168
18  GoogleInteractiveMediaAds         0x104c65854 -[IMAWKWebView userContentController:didReceiveScriptMessage:] + 180
19  WebKit                            0x18fe817dc ScriptMessageHandlerDelegate::didPostMessage(WebKit::WebPageProxy&, WebKit::FrameInfoData&&, API::ContentWorld&, WebCore::SerializedScriptValue&) + 208 (WKUserContentController.mm:155)
20  WebKit                            0x19011ef40 WebKit::WebUserContentControllerProxy::didPostMessage(WTF::ObjectIdentifier<WebKit::WebPageProxyIdentifierType>, WebKit::FrameInfoData&&, unsigned long long, IPC::ArrayReference<unsigned char, 1844... + 648 (WebUserContentControllerProxy.cpp:348)
21  WebKit                            0x1903e03c8 WebKit::WebUserContentControllerProxy::didReceiveMessage(IPC::Connection&, IPC::Decoder&) + 2556 (HandleMessage.h:57)
22  WebKit                            0x18fc00db8 IPC::MessageReceiverMap::dispatchMessage(IPC::Connection&, IPC::Decoder&) + 272 (MessageReceiverMap.cpp:129)
23  WebKit                            0x1900310c8 WebKit::WebProcessProxy::didReceiveMessage(IPC::Connection&, IPC::Decoder&) + 40 (AuxiliaryProcessProxy.cpp:247)
24  WebKit                            0x18fbde8b4 IPC::Connection::dispatchMessage(std::__1::unique_ptr<IPC::Decoder, std::__1::default_delete<IPC::Decoder> >) + 808 (Connection.cpp:1077)
25  WebKit                            0x18fbddec4 IPC::Connection::dispatchIncomingMessages() + 508 (Connection.cpp:1226)
26  JavaScriptCore                    0x18d499034 WTF::RunLoop::performWork() + 292 (Function.h:82)
27  JavaScriptCore                    0x18d49a1a4 WTF::RunLoop::performWork(void*) + 36 (RunLoopCF.cpp:46)
28  CoreFoundation                    0x1813d30d0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 (CFRunLoop.c:1972)
29  CoreFoundation                    0x1813e3d90 __CFRunLoopDoSource0 + 208 (CFRunLoop.c:2016)
30  CoreFoundation                    0x18131e098 __CFRunLoopDoSources0 + 268 (CFRunLoop.c:2053)
31  CoreFoundation                    0x1813238a4 __CFRunLoopRun + 820 (CFRunLoop.c:2951)
32  CoreFoundation                    0x181337468 CFRunLoopRunSpecific + 600 (CFRunLoop.c:3268)
33  GraphicsServices                  0x19cec238c GSEventRunModal + 164 (GSEvent.c:2200)
34  UIKitCore                         0x183cd9088 -[UIApplication _run] + 1100 (UIApplication.m:3493)
35  UIKitCore                         0x183a57958 UIApplicationMain + 2092 (UIApplication.m:5046)
36  Griffin-KWTV                      0x10303e230 main + 80 (main.m:16)
37  dyld                              0x103cf5aa4 start + 520 (dyldMain.cpp:879)

Please help with this to solve the issue.

Thanks,
Gaurav



Gaurav Purohit

unread,
Apr 11, 2022, 2:00:55 AM4/11/22
to Interactive Media Ads SDK
Hi,

Please find some more information as below:

Xcode: 13.0
IMA SDK version: 3.14.5
The crash is occurring in iOS 15 only.

When we were using version 3.11.1, we are not getting the above mail's crash issue. Actually, we have changed the below line from version 3.11.1 to 3.14.5:

From:

IMAAdDisplayContainer *container = [[IMAAdDisplayContainer alloc]  initWithAdContainer:self.adDisplayView];


To:

IMAAdDisplayContainer *container = [[IMAAdDisplayContainer alloc]  initWithAdContainer:self.adDisplayView viewController:self.parentViewController companionSlots:nil];


Our app is affected by crashes due to this.


Thanks,

Gaurav

IMA SDK

unread,
Apr 12, 2022, 2:48:11 AM4/12/22
to gau...@whizti.com, ima...@googlegroups.com

Hello Gaurav,

 

Michael here from IMA SDK Team.

 

Have you replicated the same behavior using one of our sample apps? If so, kindly share to us the screen recording of the behavior and steps to reproduce the issue so we can test on our end.

 

If the same behavior is not reproducible in our sample apps, you may also share a modified sample project implementation derived from our own samples that can replicate the issue.

 

Kindly add the VAST Tag used for testing.

 

If the file(s) you are looking to share are less than 25mb in total you can attach them to this case on your next reply. If you are having trouble attaching your file to this case or if your file(s) are larger than 25mb, you can share your files with me by performing the following steps:

 

1. Navigate to

https://docs.google.com/forms/d/e/1FAIpQLSfkAiXMeYP-fw1W3Z-tT9uwmATEKO5X6S-th0gR2ezdKaaqfg/viewform?usp=pp_url&entry.400550049=IMA+SDK&entry.460850823=5004Q00002ZLBIcQAP&entry.80707362=00101228

2. Fill out all fields, and attach your file(s).

3. Please reply back on this thread when you have uploaded your file(s). Please do not share this link.

 

Should you opt to share it directly on this thread, please send it privately via "Reply To Author" button.

Regards,

Google Logo
Michael Angelo
IMA SDK Team
 


ref:_00D1U1174p._5004Q2ZLBIc:ref

Gaurav Purohit

unread,
Apr 12, 2022, 5:46:14 AM4/12/22
to Interactive Media Ads SDK
Hi Michael,

Thanks for your reply.

We have not sample code for the project. Please find the issue described as below:

Issues description:

1. We have implemented IMA SDK but we are using our AVPlayerViewController to display our video after your IMA AD played so we did not follow your sample app in this case.

1. We are passing the correct UIViewController object in the below method. It is working fine but in some cases we got crash.

IMAAdDisplayContainer *container = [[IMAAdDisplayContainer alloc]  initWithAdContainer:self.adDisplayView viewController:currentViewController companionSlots:nil];

2. We are initializing and using our AVPlayerViewController in our app but it initialized after IMA Ad is played or it failed. Should we initialize our AVPlayerViewController before the IMA Ad request mechanism and IMA Ad played or failed?

3. Crash report is saying we are passing RootViewController object as parent view controller but we are not passing that object. We are passing the relevant parent view controller object and it is working fine with us but some users got crashes. So the crash is not reproducible by us. We are only getting crashes in Crashlytics as below:


Fatal Exception: UIViewControllerHierarchyInconsistency
child view controller:<IMAAdViewController: 0x10e66fe60> should have parent view controller:<HomePageSectionFrontController: 0x104106600> but actual parent is:<RootViewController: 0x1040cd400>

4. After IMA Ad is played or failed, we are also adding our AVPlayerViewController's view for playing our video in the same our UIView object of IMA Ad. In short, we are using same UIView object for playing IMA AD & for our Video play. Below are lines of code are executed after IMA Ad played or failed:

    self.avPlayerViewController = [[AVPlayerViewController alloc] init];
    .....
    [self.parentViewController addChildViewController:self.avPlayerViewController];
    [self.adDisplayView addSubview:self.avPlayerViewController.view];
    [self.avPlayerViewController didMoveToParentViewController:self.parentViewController];

5. Why we are passing UIViewController in the below line?

IMAAdDisplayContainer *container = [[IMAAdDisplayContainer alloc]  initWithAdContainer:self.adDisplayView viewController:currentViewController companionSlots:nil];

I hope you understand the above points. Kindly go through it.

Thanks,
Gaurav

Gaurav Purohit

unread,
Apr 15, 2022, 2:11:34 AM4/15/22
to Interactive Media Ads SDK
Hello Support Team,

I have uploaded the source code file to your given link.

It is working 97% but in some cases it is not working so we want to know if there any integration steps are missing or a better way we can integrate IMA SDK with our code.

We are already given crash reports and other things in the same email chain before.

Thanks in advance.

Thanks,
Gaurav Purohit

IMA SDK

unread,
Apr 18, 2022, 3:56:53 AM4/18/22
to gau...@whizti.com, ima...@googlegroups.com

Hello Gaurav,

 

Thank you for your response.

 

Best way to resolve SDK issues is to replicate the same behavior on our end, thus we require any sample project that can reproduce the issue so our internal team can have a closer look when we raise the issue to them.

 

Additionally, I do not find any source code you mentioned in your previous response. In sharing files, please follow the process I gave on my last response.

 

On the other hand, since you mentioned that you did not explicitly follow our sample apps, we would recommend to check it back again and use for your own reference as custom implementations may lead to unexpected behavior when the flow of the SDK is not followed. Please check the guidance below for SDK's lifecycle:

Gaurav Purohit

unread,
Apr 18, 2022, 4:04:34 AM4/18/22
to Interactive Media Ads SDK

Hello Support Team,

Thanks for your reply.

I have uploaded the source code below link given by you:


I have again uploaded the source code. Let me know if you do not find it.

Thanks,
Gaurav

IMA SDK

unread,
Apr 20, 2022, 1:40:27 AM4/20/22
to gau...@whizti.com, ima...@googlegroups.com

Hello Gaurav,

 

Thank you for sharing additional information.

 

However, I am uncertain if I am seeing the exact behavior you are seeing on your end as the app stops working right from opening. Would you be able to share screen recording of the behavior for better illustration of the issue?

 

Additionally, if this sample app is derived from our own basic sample app, would you please make a summary of the changes and highlight it, so it would be clear to our internal teams when we raise this to them, it will greatly help for faster progression of the investigation.

Regards,

Gaurav Purohit

unread,
Apr 22, 2022, 1:12:28 AM4/22/22
to Interactive Media Ads SDK
Hello Support Team,

Thanks for your reply.

We are not getting this issue so we do not have a screen recording of the behaviour. The crash happens in 3% of cases and 97% worked fine.

I have already provided source code that is derived from your basic sample app. Could you confirm integration of IMA SDK is fine?

Thanks,
Gaurav

IMA SDK

unread,
Apr 25, 2022, 11:13:35 PM4/25/22
to gau...@whizti.com, ima...@googlegroups.com

Hello Gaurav,

 

Thank you for your response. I wasn't able to run the shared application due to security reasons. With this, would you be able to share the exact sample VAST Tag used in the shared sample app? Upon submitting, I will raise this to the rest of our team for further investigation.

 

You may send the requested details privately via "Reply To Author" button.

Regards,

Gaurav Purohit

unread,
Apr 29, 2022, 2:03:14 AM4/29/22
to Interactive Media Ads SDK
Hello Team,

I have submitted the requested details by "Reply To Author" option to you.

Thanks,
Gaurav

IMA SDK

unread,
May 4, 2022, 7:24:27 AM5/4/22
to gau...@whizti.com, ima...@googlegroups.com

Hello Gaurav,

 

We have received the requested details. With that, I have raised the issue to our wider team to get their insights as well and provide a more precise answer to your integration concern. Kindly wait patiently for their response.

Regards,

IMA SDK

unread,
Jul 11, 2022, 2:17:35 PM7/11/22
to ima...@googlegroups.com, gau...@whizti.com
Hi Guarav,

Sorry for the late reply on this. Your case was accidentally misrouted during escalation, and only recently made it to my desk. That said, I have good news. The latest version of the IMA SDK for iOS (3.16.3) has a fix for this issue. If you update to the latest version, it should be resolved.

Thanks,

Greg Schoppe
Reply all
Reply to author
Forward
0 new messages