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

App crash when receiving notification #763

Closed
EmanuelDavid opened this issue Oct 9, 2020 · 9 comments
Closed

App crash when receiving notification #763

EmanuelDavid opened this issue Oct 9, 2020 · 9 comments

Comments

@EmanuelDavid
Copy link

EmanuelDavid commented Oct 9, 2020

Description:
App crash pretty rarely, so rare I cannot reproduce it but on app store we have 10 crashes

Environment

  1. OneSignal version 2.15.3
    2.Installed with CocoaPods
    3.Project is in Swift

Steps to Reproduce Issue:
I am not sure, it seems, from the stack trace that it crashes when a notification is received. But it does not crash in my notification action callback or so.

Anything else:
Our project was using carthage, but when we have integrate google analytics, we moved to CocoaPods. Since then the crash started to happen.
This are the logs, with the stack trace, it seems to be crashing in OneSignalNotificationServiceExtensionHandler.m at line 104.

Incident Identifier: 7E78C42F-E991-4A90-879E-FBAF93F32B3A
Hardware Model: iPad8,5
Process: OneSignalNotificationServiceExtension [1824]
Path: /private/var/containers/Bundle/Application/3B70D76A-77E9-4BC8-9CF8-7AF65DCB2DF1/LimeLife.app/PlugIns/OneSignalNotificationServiceExtension.appex/OneSignalNotificationServiceExtension
Identifier: com.*****.OneSignal
Version: 0 (1.0.7)
AppVariant: 1:iPad8,5:13
Code Type: ARM-64 (Native)
Role: Unspecified
Parent Process: launchd [1]

Date/Time: 2020-10-06 23:30:13.8502 -0500
Launch Time: 2020-10-06 23:30:13.3520 -0500
OS Version: iPhone OS 13.7 (17H35)
Release Type: User
Baseband Version: n/a
Report Version: 104

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000020
VM Region Info: 0x20 is not in any region. Bytes before following region: 4341022688
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
--->

  __TEXT                 0000000102bec000-0000000102c44000 [  352K] r-x/r-x SM=COW  ...viceExtension

Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [1824]
Triggered by Thread: 1

Thread 1 name:
Thread 1 Crashed:
0 libobjc.A.dylib 0x00000001a066bdc0 objc_release + 16 (objc-object.h:551)
1 ...otificationServiceExtension 0x0000000102c283d0 +[OneSignalNotificationServiceExtensionHandler onNotificationReceived:] + 292 (OneSignalNotificationServiceExtensionHandler.m:104)
2 ...otificationServiceExtension 0x0000000102c27fd0 +[OneSignalNotificationServiceExtensionHandler didReceiveNotificationExtensionRequest:withMutableNotificationContent:] + 368 (OneSignalNotificationServiceExtensionHandler.m:60)
3 ...otificationServiceExtension 0x0000000102bff73c +[OneSignal didReceiveNotificationExtensionRequest:withMutableNotificationContent:] + 56 (OneSignal.m:2352)
4 ...otificationServiceExtension 0x0000000102bf2ca0 specialized NotificationService.didReceive(:withContentHandler:) + 380 (:25)
5 ...otificationServiceExtension 0x0000000102bf28c4 didReceive + 12 (:0)
6 ...otificationServiceExtension 0x0000000102bf28c4 @objc NotificationService.didReceive(
:withContentHandler:) + 76
7 UserNotifications 0x00000001a7e0edf4 -[_UNNotificationServiceExtensionRemoteContext didReceiveNotificationRequest:withCompletionHandler:] + 444 (_UNNotificationServiceExtensionRemoteContext.m:53)
8 Foundation 0x00000001a0e4b894 NSXPCCONNECTION_IS_CALLING_OUT_TO_EXPORTED_OBJECT_S2

  • 16 (NSXPCConnection.m:151)
    9 Foundation 0x00000001a0c55b00 -[NSXPCConnection _decodeAndInvokeMessageWithEvent:flags:] + 1756 (NSXPCConnection.m:655)
    10 Foundation 0x00000001a0e4b9b8 message_handler + 228 (NSXPCConnection.m:734)
    11 libxpc.dylib 0x00000001a0534bc0 _xpc_connection_call_event_handler + 140 (connection.c:672)
    12 libxpc.dylib 0x00000001a0534f40 _xpc_connection_mach_event + 876 (connection.c:1208)
    13 libdispatch.dylib 0x00000001a05dd678 _dispatch_client_callout4 + 20 (object.m:535)
    14 libdispatch.dylib 0x00000001a05f43f8 _dispatch_mach_msg_invoke + 376 (mach.c:2442)
    15 libdispatch.dylib 0x00000001a05e3934 _dispatch_lane_serial_drain + 264 (inline_internal.h:2525)
    16 libdispatch.dylib 0x00000001a05f502c _dispatch_mach_invoke + 464 (mach.c:2764)
    17 libdispatch.dylib 0x00000001a05e3934 _dispatch_lane_serial_drain + 264 (inline_internal.h:2525)
    18 libdispatch.dylib 0x00000001a05e44cc _dispatch_lane_invoke + 452 (queue.c:3863)
    19 libdispatch.dylib 0x00000001a05eda5c _dispatch_workloop_worker_thread + 584 (queue.c:6445)
    20 libsystem_pthread.dylib 0x00000001a0643718 _pthread_wqthread + 276 (pthread.c:2352)
    21 libsystem_pthread.dylib 0x00000001a06499c8 start_wqthread + 8

Thread 2 crashed with ARM Thread State (64-bit):
x0: 0x0000000100722020 x1: 0x00000001f461803d x2: 0x0000000000000006 x3: 0x000000010233d340
x4: 0x000000010233d0d0 x5: 0x0000000000000008 x6: 0x0000000000000000 x7: 0x0000000000000000
x8: 0x0000000010072af0 x9: 0x30fbd7ff5d9700b6 x10: 0x000000020000078c x11: 0x003f00010180cc00
x12: 0x00000002f3f70605 x13: 0x000001a2061649e9 x14: 0x0000000064408071 x15: 0x00000000000027b7
x16: 0x00000001b7ab9db0 x17: 0x910ffc81b7c6c74c x18: 0x0000000000000000 x19: 0x00000001007211f0
x20: 0x00000001004e9a18 x21: 0x000000010233d340 x22: 0x00000001f4d68386 x23: 0x0000000100722020
x24: 0x00000001004e8000 x25: 0x0000000100721310 x26: 0x0000000102334ae0 x27: 0x0000000000000001
x28: 0x000000010071d200 fp: 0x000000016fab5640 lr: 0x0000000100496010
sp: 0x000000016fab5600 pc: 0x00000001b7ab9dc0 cpsr: 0x60000000
esr: 0x92000006 (Data Abort) byte read Translation fault

@emawby
Copy link
Contributor

emawby commented Oct 14, 2020

Hello what is your log level and visual log level? This crash seems to be coming from a memory management issue when we are trying to print to the log, but I am not sure exactly what object is being mis-managed.

@EmanuelDavid
Copy link
Author

Hi, I do not set any log level so I assume it is:
static ONE_S_LOG_LEVEL _nsLogLevel = ONE_S_LL_WARN;
static ONE_S_LOG_LEVEL _visualLogLevel = ONE_S_LL_NONE;

@EmanuelDavid
Copy link
Author

The problem is that I can not reproduce it. @emawby would it help if I set:
OneSignal.setLogLevel(.LL_NONE, visualLevel: .LL_NONE) ??

@emawby
Copy link
Contributor

emawby commented Oct 15, 2020

It might but if we are not able to reproduce the issue it is hard to say. If you are able to reproduce it using the common memory debugging tools in Xcode would help. I apologize for not being more helpful but un-reproducable memory issues like this are difficult to track down

@AhrenFullStop
Copy link

I am having similar but persistent issue with the app on IOS claiming to be on line 194 of OneSignalPush.m. I'm creating an Ionic 4 app with push notification capability. This seems to work perfectly on older IOS devices, but newer ones (IOS 14+) seem to crash.

https://github.com/OneSignal/OneSignal-Cordova-SDK/blob/22660bd5e48cc38c13b2e4268fa42d048ebbb94b/src/ios/OneSignalPush.m#L194

The last 10 items on the crash backtrace are:

Last Exception Backtrace:
0   CoreFoundation                	0x1af14a5ac __exceptionPreprocess + 220 (NSException.m:199)
1   libobjc.A.dylib               	0x1c323842c objc_exception_throw + 60 (objc-exception.mm:565)
2   CoreFoundation                	0x1af054a2c -[NSObject(NSObject) doesNotRecognizeSelector:] + 144 (NSObject.m:146)
3   CoreFoundation                	0x1af14d130 ___forwarding___ + 1444 (NSForwarding.m:3597)
4   CoreFoundation                	0x1af14f420 _CF_forwarding_prep_0 + 96
5   School Bozza                  	0x1042d7620 -[OneSignalPush init:] + 676 (OneSignalPush.m:194)
6   School Bozza                  	0x10432c68c 0x1042bc000 + 460428
7   School Bozza                  	0x1042c7a90 -[CDVWKWebViewEngine handleCordovaMessage:] + 180 (CDVWKWebViewEngine.m:616)
8   School Bozza                  	0x1042c794c -[CDVWKWebViewEngine userContentController:didReceiveScriptMessage:] + 124 (CDVWKWebViewEngine.m:602)
9   School Bozza                  	0x1042c8c14 -[CDVWKWeakScriptMessageHandler userContentController:didReceiveScriptMessage:] + 100 (CDVWKWebViewEngine.m:822)
10  WebKit                        	0x1bb3bd4c4 ScriptMessageHandlerDelegate::didPostMessage(WebKit::WebPageProxy&, WebKit::FrameInfoData&&, API::ContentWorld&, WebCore::SerializedScriptValue&) + 232 (WKUserContentController.mm:148)

Line 5 gives us what I think is the culprit.

Things I've already tried:

  • Older version of the Podfile
  • Remove and add back ios platform
  • Remove and add cordova plugin
  • Different versions of cordova plugin
  • Adding in a 'setTimeout' to delay the initialization somewhat
  • my current Pod version is 2.15.2

Nothing seems to work. I am initializing in my app.component.ts within the platform. ready function like this:

initializeApp() {
    this.platform.ready().then(() => {
      this.statusBar.styleDefault();
      this.splashScreen.hide();
      setTimeout(() => {
        this.oneSignalInit();
        this.uId.get().then((uuid: any) => {});
      }, 1000);
    });
  }

And then I'm running the init like this:

oneSignalInit() {
    try {
      // set onesignal id
      const oldId = localStorage.getItem('onesignal_id');
      if (oldId && oldId.length > 0) {
        console.log('We have already registered with one signal');
      } else {
        if (this.platform.is('ios')) {
          this.oneSignal.addTrigger("prompt_ios", "true");
          this.oneSignal.startInit(environment.ONESIGNAL_APP_ID, '');
        } else {
          this.oneSignal.startInit(environment.ONESIGNAL_APP_ID, environment.FIREBASE_SENDERID);
        }
        // notification configuration
        this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.Notification); 
        this.oneSignal.setSubscription(true);
        this.oneSignal.enableVibrate(true);
        this.oneSignal.enableSound(true);
        try {
          // get unique id from onesignal and register with device
          this.oneSignal.getIds().then((usersIds: any) => {
            console.log('Registered with onesignal');
            localStorage.setItem('onesignal_id', usersIds.userId);
          }).catch((err: any) => {
            console.log(err, 'one');
          });
        } catch (e) {
          console.log(e);
        }
      }
      this.oneSignal.endInit();
    } catch (e) {
      console.log(e, 'try');
      this.oneSignal.endInit();
    }
  }

Please if anyone can be of assistance, it would be amazing, I can't even imagine what the issue could be, others don't seem to face the same issue, so it must be something stupid that I'm doing.

@EmanuelDavid
Copy link
Author

EmanuelDavid commented Oct 27, 2020

Since last time, I have 20 more crashes, one has additional steps in the stack trace, maybe it helps on the track down:

Thread 4 name:
Thread 4 Crashed:
0 libobjc.A.dylib objc_release + 16 (objc-object.h:756)
1 ...otificationServiceExtension -[OSSessionManager init:withTrackerFactory:] + 144 (OSSessionManager.m:51)
2 ...otificationServiceExtension +[OneSignal sessionManager] + 112 (OneSignal.m:396)
3 ...otificationServiceExtension +[OneSignalNotificationServiceExtensionHandler onNotificationReceived:] + 200 (OneSignalNotificationServiceExtensionHandler.m:104)
4 ...otificationServiceExtension +[OneSignalNotificationServiceExtensionHandler didReceiveNotificationExtensionRequest:withMutableNotificationContent:] + 368 (OneSignalNotificationServiceExtensionHandler.m:60)
5 ...otificationServiceExtension +[OneSignal didReceiveNotificationExtensionRequest:withMutableNotificationContent:] + 56 (OneSignal.m:2352)
6 ...otificationServiceExtension (:11)
8 UserNotifications -[_UNNotificationServiceExtensionRemoteContext didReceiveNotificationRequest:withCompletionHandler:] + 428 (_UNNotificationServiceExtensionRemoteContext.m:53)
9 Foundation NSXPCCONNECTION_IS_CALLING_OUT_TO_EXPORTED_OBJECT_S2 + 12 (NSXPCConnection.m:272)
10 Foundation -[NSXPCConnection _decodeAndInvokeMessageWithEvent:flags:] + 1736 (NSXPCConnection.m:787)
11 Foundation message_handler + 224 (NSXPCConnection.m:866)
12 libxpc.dylib _xpc_connection_call_event_handler + 68 (connection.c:0)
13 libxpc.dylib _xpc_connection_mach_event + 880 (connection.c:1218)
14 libdispatch.dylib _dispatch_client_callout4 + 16 (object.m:599)
15 libdispatch.dylib _dispatch_mach_msg_invoke$VARIANT$armv81 + 376 (mach.c:2429)
16 libdispatch.dylib _dispatch_lane_serial_drain$VARIANT$armv81 + 260 (inline_internal.h:2589)
17 libdispatch.dylib _dispatch_mach_invoke$VARIANT$armv81 + 464 (mach.c:2751)
18 libdispatch.dylib _dispatch_lane_serial_drain$VARIANT$armv81 + 260 (inline_internal.h:2589)
19 libdispatch.dylib _dispatch_lane_invoke$VARIANT$armv81 + 456 (queue.c:3862)
20 libdispatch.dylib _dispatch_workloop_worker_thread + 692 (queue.c:6590)
21 libsystem_pthread.dylib _pthread_wqthread + 272 (pthread.c:2194)
22 libsystem_pthread.dylib start_wqthread + 8

So this time the app crashes at
_sessionManager = [[OSSessionManager alloc] init:self withTrackerFactory:OneSignal.trackerFactory];

@AhrenFullStop
Copy link

Okay so I found the issue, so in my app initialization I used:

this.oneSignal.startInit(environment.ONESIGNAL_APP_ID, ' ');

But the issue was actually a null string, meaning that the app was not successfully importing that variable. I fixed that by simply hardcoding the App ID in the actual OneSignalPush.m file... It's not good practice but it stops the app from crashing.

@rgomezp
Copy link
Contributor

rgomezp commented Oct 28, 2020

@AhrenFullStop ,
I noticed you commented similarly on:
#248
#739 (comment)
#504

These seem like separate issues, but I take it that one change resolved all of them for you?

@EmanuelDavid
Copy link
Author

EmanuelDavid commented Feb 3, 2021

The bug was not related to one signal, is just the stack trace absolutely not on target. The issue was generated by attempting to read a nil object

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants