Weird Crash Issue on AppResume

hi folks,

I was asked to take up a fairly old corona app for a friend of mine (still uses director and v1 graphics) and helped him upgrade it to latest solar2d version including plugins.

Most things are ok, but I faced 2 errors which I’ve not been able to figure out so was hoping if anyone else had already found a solution or had knowledge about could help me out, as these were causing large number of crashes in production.

Also thankful to the thread on this forum around crashlytics and debugging for helping me find bugsnag (kudos agramonte for the plugin) in addition to firebase crashlytics as tools to diagnose crash related issues on live user devices remotely, that was a major help

Both these issues are not locally reproducible which is part of the challenge,

1st one is,
Attempted to dereference garbage pointer

and 2nd one was something I raised with Scott already, I was using his ironSource plugin along side the admob native plugin by solar2d just for banner ads, see below bugsnag output/similar to crashlytics,

CrashReporter Key: -
Hardware Model: iPhone13,4
Process: -
Identifier: -
Version: -
Role: Foreground
OS Version: iOS 18.2

NSGenericException: Unable to activate constraint with anchors <NSLayoutXAxisAnchor:0x30075e000 “GADBannerView:0x10e6ee000.centerX”> and <NSLayoutXAxisAnchor:0x300753580 “CoronaView:0x102c92200.centerX”> because they have no common ancestor. Does the constraint or its anchors reference items in different view hierarchies? That’s illegal.

0 CoreFoundation +0x2d5e8 ___exceptionPreprocess
1 libobjc.A.dylib +0x31240 _objc_exception_throw
2 CoreAutoLayout +0xbb58 -[NSLayoutConstraint _setActive:mutuallyExclusiveConstraints:]
3 CoreAutoLayout +0xb278 ___55+[NSLayoutConstraint _addOrRemoveConstraints:activate:]_block_invoke
4 CoreAutoLayout +0xc548 -[NSISEngine withBehaviors:performModifications:]
5 CoreAutoLayout +0xb94c +[NSLayoutConstraint _addOrRemoveConstraints:activate:]
6 myAPP +0xb07b6c -[CoronaAdMobAdInstance positionBannerViewInsideSafeAreaiOS9Plus:withYAlign:withYOffset:] (AdMobPlugin.mm)
7 libdispatch.dylib +0x2244 __dispatch_call_block_and_release
8 libdispatch.dylib +0x3fa4 __dispatch_client_callout
9 libdispatch.dylib +0x12a30 __dispatch_main_queue_drain
10 libdispatch.dylib +0x12648 __dispatch_main_queue_callback_4CF
11 CoreFoundation +0x79bb8 _CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE
12 CoreFoundation +0x761ac ___CFRunLoopRun
13 CoreFoundation +0xc8270 _CFRunLoopRunSpecific
14 GraphicsServices +0x14bc _GSEventRunModal
15 UIKitCore +0x3ee778 -[UIApplication _run]
16 UIKitCore +0x14e60 _UIApplicationMain

I will try remove admobplugin and try use ironSource banner instead as an alternative, but wanted to hear if anyone else faced above and was able to resolve them. Thanks

For the admobPlugin issue, im using ironSource with admob adaptor as well for google bidding alongside this one, but only for interstitials, so not sure if any conflicts due to that but thought I’d mention it just in case

To me, the first one looks like it’s a failed someGroup:insert(someObject) call - presumably the object has been removed but not nilled (my guess would be it was in a group/scene which has been destroyed but the reference to the object itself still exists).

To make things slightly easier to track in Bugsnag, I overwrote the print function so that it would instead record a breadcrumb in live builds. Something like this:

if system.getInfo("environment") ~= "simulator" then
	
	print = function(...)

		local printLine = ""
		for i = 1, #arg do
			printLine = printLine .. tostring(arg[i]) .. ", "
		end
		
		bugsnagManager:leaveBreadcrumb(printLine)
	end
end

Thats a great idea Alan, let me add this in as well.

I didn’t know lua can cause a native exception if handled properly, as I’m catching unhandled exceptions and most come into that where I log them cleanly. Let me try review the code in the area as ive got breadcrumbs to see if any group/insert exists. This also happens on App resume only but is very rare which is why its a pain to diagnose.

@hraza Look at finalize method.
I also encountered the same problem with the stack, LuaGroupObjectProxyVTable::Insert, but it is not clear if it is the same cause.
It is possible that executing group:insert(obj) in the obj's finalize method crashes, either because obj is nil, or because obj._proxy is nil.

This app has no native code other than using plugins, so there was nothing added in finalize method from what I could tell atleast. Is there a lua variant of the finalize method that I should check ?

I’m sorry I wasn’t clear. I was referring to finalize events.

BTW, share your build.settings or a list of plugins you use so that people can better analyze the issues with your application.

I will look for that, haven’t seen it but as the app uses director and very old code, it might be lying around somewhere.

Plugins are as under, the file was a bit of a mess so sharing after redacting stuff,

plugins =
{	
	--dependencies for other plugins
    ["plugin.apple.iap"] =
    {
        publisherId = "com.coronalabs",
        supportedPlatforms = { iphone=true }
    },	
    ["plugin.apple.iap.helper"] = { publisherId = "com.coronalabs", supportedPlatforms = { iphone=true } },
	['plugin.att'] = { publisherId = 'com.solar2d',supportedPlatforms = { iphone=true } },
	["shared.google.play.services.location"] = {publisherId = "com.coronalabs", supportedPlatforms = { android=true }},
	["shared.google.play.services.ads"] = {publisherId = "com.coronalabs", supportedPlatforms = { android=true }},
	
	--["plugin.fabric"] = { publisherId = "tech.scotth", supportedPlatforms = { iphone=true} },
	["shared.firebase.messaging"] = {publisherId = 'com.coronalabs', supportedPlatforms = { android=true, iphone=false }},
	["plugin.firebaseAnalytics"] = { publisherId = "tech.scotth", marketplaceId = "", supportedPlatforms = { android=true, iphone=true }},

	["plugin.firebaseCrashlytics"] =
	{
		publisherId="tech.scotth",
		marketplaceId = "",
	},
	
	["plugin.bugsnag"] = 
	{
    	publisherId = "com.cabagomez"
	},


	["plugin.gameanalytics_v2"] =
	{
		publisherId = "com.gameanalytics",
		supportedPlatforms = {
			android = { url="https://www.solar2dplugins.com/download/gameanalytics/agramonte/4fcd15145e5617a52bec63ce09beed2158820fe2-android.tar.gz" },
			iphone = false,
        }
    },

    ["shared.android.support.v4"] = {publisherId = "com.coronalabs", supportedPlatforms = { android=true } },
    ["plugin.advertisingId"] = { publisherId = "com.coronalabs" },        
    ["plugin.notifications.v2"] = { publisherId = "com.coronalabs" },
    ["plugin.openssl"] = { publisherId = "com.coronalabs", },
    
    ["plugin.touchId"] =
	{
		publisherId="tech.scotth",
		marketplaceId = "",
	},
    
    
    ["plugin.safariWebview"] =  { 
    	publisherId = "tech.scotth",  
    	marketplaceId = "",
	},
    
    ["plugin.amplitude"] =
    {
        publisherId = "games.flick",
        supportedPlatforms = { 
            iphone = { url="https://alanflickgames.github.io/downloads/amplitude_iphone.tgz" },
            android = { url="https://alanflickgames.github.io/downloads/amplitude_android.tgz" },
            macos = false,
            win32 = false,
        },
    },


 	--Adapters
 	["ironsource.applovin"] = {
		publisherId = "tech.scotth",
		supportedPlatforms = { 
            iphone = false,
            android = true
        },			
	},
	
	["ironsource.admob"] = {
		publisherId = "tech.scotth",
		supportedPlatforms = { 
            iphone = true,
            android = true
        },			
	},

	["ironsource.unityAds"] = {
		publisherId = "tech.scotth",
		supportedPlatforms = { 
            iphone = true,
            android = true
        },	
	},

	["plugin.ironSource"] =
	{
		publisherId="tech.scotth",
		marketplaceId = "",
		supportedPlatforms = { 
            iphone = true,
            android = true
        },
	},

    --standalone admob - ios only
    ["plugin.admob"] = { 
        publisherId = "com.coronalabs",
        supportedPlatforms = { 
            android=false, 
            iphone=true 
        }
    },
        
    
    ["plugin.unityads.v4"] =
    {
        publisherId = "com.solar2d",
        supportedPlatforms = { 
            iphone = false,
            android = false, 
        },
    },
    
    ["plugin.google.iap.billing.v2"] =
    {
         publisherId = "com.solar2d"
    },



    ["plugin.locperm"] =
    {
        publisherId = "com.plantpot",
    },
    

},