newrelic / newrelic-capacitor-plugin

Mobile instrumentation plugin for the Capacitor hybrid mobile platform by Ionic
Apache License 2.0
7 stars 10 forks source link

NewRelic.start() fails with error "All launch handlers must be registered before application finishes launching" #91

Open mwang-incomm opened 2 weeks ago

mwang-incomm commented 2 weeks ago

Encountering an error during ios app launch. Exception is thrown when NewRelic.start() method is called. Any ideas why this error is being thrown?

Description

The error "All launch handlers must be registered before application finishes launching" is thrown in XCode when app launches.

Steps to Reproduce

Created a new ionic app using ionic start Selected the list template and chose angular as the framework Followed the directions on NewRelic to install the capacitor plugin and set up the ios agent Run the ionic app in XCode and error is encountered and so the App fails to load

Expected Behavior

App runs and NewRelic monitoring is enabled

Relevant Logs / Console output

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'All launch handlers must be registered before application finishes launching' First throw call stack: ( 0 CoreFoundation 0x00007ff80049b761 exceptionPreprocess + 242 1 libobjc.A.dylib 0x00007ff800063904 objc_exception_throw + 48 2 Foundation 0x00007ff800dab980 _userInfoForFileAndLine + 0 3 BackgroundTasks 0x00007ff8377352ed -[BGTaskScheduler _unsafe_registerForTaskWithIdentifier:usingQueue:launchHandler:] + 445 4 BackgroundTasks 0x00007ff8377350ec -[BGTaskScheduler registerForTaskWithIdentifier:usingQueue:launchHandler:] + 164 5 NewRelic 0x000000010f9d93ea -[NewRelicAgentInternal initWithCollectorAddress:crashCollectorAddress:andApplicationToken:] + 339 6 NewRelic 0x000000010f9ddb9a __96+[NewRelicAgentInternal startWithApplicationToken:andCollectorAddress:andCrashCollectorAddress:]_block_invoke + 104 7 libdispatch.dylib 0x000000010e7e69f7 _dispatch_client_callout + 8 8 libdispatch.dylib 0x000000010e7e8095 _dispatch_once_callout + 66 9 NewRelic 0x000000010f9ddb21 +[NewRelicAgentInternal startWithApplicationToken:andCollectorAddress:andCrashCollectorAddress:] + 743 10 NewRelic 0x000000010f9dd817 +[NewRelicAgentInternal startWithApplicationToken:andCollectorAddress:] + 364 11 NewrelicNewrelicCapacitorPlugin 0x000000010e7a60e1 $s08NewrelicA15CapacitorPlugin08NewRelicbcC0C5startyySo13CAPPluginCallCFyyScMYccfU_Tf2innn_n + 641 12 NewrelicNewrelicCapacitorPlugin 0x000000010e7a63c8 $sIeg_IeyB_TR + 40 13 libdispatch.dylib 0x000000010e7e5747 _dispatch_call_block_and_release + 12 14 libdispatch.dylib 0x000000010e7e69f7 _dispatch_client_callout + 8 15 libdispatch.dylib 0x000000010e7f6856 _dispatch_main_queue_drain + 1362 16 libdispatch.dylib 0x000000010e7f62f6 _dispatch_main_queue_callback_4CF + 31 17 CoreFoundation 0x00007ff8003f7dc4 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 9 18 CoreFoundation 0x00007ff8003f26ff CFRunLoopRun + 2463 19 CoreFoundation 0x00007ff8003f197d CFRunLoopRunSpecific + 557 20 GraphicsServices 0x00007ff80fe9d08f GSEventRunModal + 137 21 UIKitCore 0x00007ff805bbb53d -[UIApplication _run] + 972 22 UIKitCore 0x00007ff805bbffab UIApplicationMain + 123 23 App 0x000000010d7544cf main + 63 24 dyld 0x000000010dc023e0 start_sim + 10 25 ??? 0x000000011cbf7366 0x0 + 4777276262 ) libc++abi: terminating due to uncaught exception of type NSException Type: stdio

Your Environment

XCode version 15.2 Angular 18 Capacitor 6 newrelic-capacitor-plugin 1.4.1

Toxiapo commented 1 week ago

I am also experiencing the same bug with our app and it is blocking us from upgrading our app to Capacitor 6.

I've created a testing app with everything updated to their latest versions, and there's a branch that includes our attempt to fix the bug but was not successful. Hope they help with the debugging. @ndesai-newrelic

The bug only occurs on Capacitor@6 and we believe it had something to do with where Capacitor6 now requires manually register custom plugin.

mwang-incomm commented 1 week ago

After some research into this issue, I think this is related to the usage of background execution in the new ios agent from NewRelic. According to NewRelic's documentation, we need to call NewRelic.start() in the AppDelegate. Not sure if there is a way to do this through the plugin? If not, I think we might be stuck with calling the NewRelic agent directly in our app.

johnfitz00 commented 1 week ago

Also seeing this issue on a fresh install trying to set up the plugin for the first time.

Xcode: Version 15.4 (15F31d) Angular 17 Capacitor 6 newrelic-capacitor-plugin 1.4.1

devand123 commented 1 week ago

Also now just seeing this issue on:

Xcode: Version 15.4 Capacitor 5.7.4 newrelic-capacitor-plugin 1.3.7

ndesai-newrelic commented 5 days ago

@mwang-incomm this is on our priority list, I am working on it to fix this issue.

ndesai-newrelic commented 5 days ago

@mwang-incomm can you check in latest release where we disabled background reporting for now?

mwang-incomm commented 5 days ago

@ndesai-newrelic yes I can confirm that 1.4.2 now works on ios and I no longer see the error

johnfitz00 commented 4 days ago

I can also confirm that 1.4.2 I no longer see the error, thanks @ndesai-newrelic :)