braze-inc / braze-react-native-sdk

Public repo for the Braze React Native SDK
https://www.braze.com
Other
64 stars 84 forks source link

[Bug]: iOS 13 crashes after receiving In-App Message #239

Closed richardscheid closed 4 months ago

richardscheid commented 11 months ago

Which Platforms?

iOS

Which React Native Version?

0.71.14

Which @braze/react-native-sdk SDK version?

8.0.0

Repro Rate

100% of the time

Steps To Reproduce

  1. Open the iOS app.
  2. Send an In-App Message to the user.
  3. IAM is shown as expected, close the message.
  4. Attempt to open an action sheet, the app crashes.

If the IAM is not sent, the action sheet works as expected. Or, if I close the app and open it again, the action sheet works again.

Expected Behavior

As for iOS 14 and above, the user should be able to keep using the action sheet after receiving the IAM.

Actual Incorrect Behavior

After receiving IAM, the app crashes when attempting to open an action sheet.

Verbose Logs

Fatal Exception: NSInvalidArgumentException
*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]

Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x12b80c __exceptionPreprocess
1  libobjc.A.dylib                0x5fa4 objc_exception_throw
2  CoreFoundation                 0x181350 -[__NSCFString characterAtIndex:].cold.1
3  CoreFoundation                 0x18a6b4 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:].cold.5
4  CoreFoundation                 0x1850c -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]
5  CoreFoundation                 0xa3a0 +[NSDictionary dictionaryWithObjects:forKeys:count:]
6  InvoiceSimple                  0x803a3c -[RCTActionSheetManager showActionSheetWithOptions:callback:] + 110 (RCTActionSheetManager.mm:110)
7  CoreFoundation                 0x131c10 __invoking___
8  CoreFoundation                 0x1b00 -[NSInvocation invoke]
9  CoreFoundation                 0x26d8 -[NSInvocation invokeWithTarget:]
10 InvoiceSimple                  0xa55240 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 587 (RCTModuleMethod.mm:587)
11 InvoiceSimple                  0xa573c8 facebook::react::invokeInner(RCTBridge*, RCTModuleData*, unsigned int, folly::dynamic const&, int, (anonymous namespace)::SchedulingContext) + 183 (RCTNativeModule.mm:183)
12 InvoiceSimple                  0xa57050 invocation function for block in facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int) + 419 (Optional.h:419)
13 libdispatch.dylib              0x5b610 _dispatch_call_block_and_release
14 libdispatch.dylib              0x5c184 _dispatch_client_callout
15 libdispatch.dylib              0xe190 _dispatch_main_queue_callback_4CF$VARIANT$mp
16 CoreFoundation                 0xa93a8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
17 CoreFoundation                 0xa439c __CFRunLoopRun
18 CoreFoundation                 0xa38a0 CFRunLoopRunSpecific
19 GraphicsServices               0x3328 GSEventRunModal
20 UIKitCore                      0xa01740 UIApplicationMain
21 InvoiceSimple                  0x6aa4 main + 15 (main.m:15)
22 libdyld.dylib                  0x1360 start

I've already checked that we are not passing any null values as the log indicates.

Additional Information

import "AppDelegate.h"

import <React/RCTBundleURLProvider.h>

import <React/RCTLinkingManager.h>

import <UserNotifications/UserNotifications.h>

import

import

import "Firebase.h"

import "Orientation.h"

import "AppsFlyerLib/AppsFlyerLib.h"

import <BrazeKit/BrazeKit-Swift.h>

import "BrazeReactBridge.h"

@implementation AppDelegate

static NSString const brazeApiKey = @"..."; static NSString const brazeEndpoint = @"...";

pragma mark - AppDelegate.braze

static Braze *_braze = nil;

// Required to register for notifications

// Required for the register event.

// Required for the notification event. You must call the completion handler after handling the remote notification.

// Required for the registrationError event.

// IOS 10+ Required for localNotification event

//Called when a notification is delivered to a foreground app. -(void)userNotificationCenter:(UNUserNotificationCenter )center willPresentNotification:(UNNotification )notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler { completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge); }

if RCT_DEV

hokstuff commented 11 months ago

Hi @richardscheid,

Thanks for raising this and providing the context. There appears not to be any Braze code based on the stack trace you provided. Could this crash be related to other parts of your code?

richardscheid commented 11 months ago

Hey Daniel,

Yes, I've considered that, but as the issue only happens after the IAM is shown, I thought to come here first. Also, In-App Browser stops working after the IAM as well (stays inactive, no crashes). So, I have two different libraries facing issues. None of these issues happens with iOS 14 and above. Could it be a compatibility issue?

react-native-inappbrowser-reborn: 3.7.0 @expo/react-native-action-sheet: 4.0.0

hokstuff commented 11 months ago

Hi @richardscheid,

I see, it also appears that you are using a few other libraries that you mentioned which may also be related to this incompatibility:

react-native-inappbrowser-reborn: 3.7.0
@expo/react-native-action-sheet: 4.0.0

Can you contact support@braze.com with more info:

  1. Verbose logging when you are able to reproduce the issue
  2. The campaigns that you are using to repro
    • Does this behavior occur for all in-app message campaigns, or just specific ones?
  3. Are you able to reproduce this behavior in a minimally-integrated sample application with Braze and as few other packages as possible? We aren't sure if there is incompatibility with our SDK, the 3rd party SDKs, or issues when using both together
    • If you are able to use the Braze SDK with a native implementation of the action sheet, that would indicate the issue is with the Braze SDK rather than the other possibilities

Thanks!

richardscheid commented 11 months ago

Hi @hokstuff,

Thanks, I'll contact the support team.

Does this behavior occur for all in-app message campaigns, or just specific ones?

It's happening to all campaigns.

If you are able to use the Braze SDK with a native implementation of the action sheet, that would indicate the issue is with the Braze SDK rather than the other possibilities

This was a great suggestion and the issue persists with the native implementation (ActionSheetIOS). Same stack trace.

jerielng commented 9 months ago

Hi @richardscheid, just wanted to check in on this issue. Are you still experiencing this/were you able to get additional assistance from our support team?

jerielng commented 4 months ago

Closing out this issue due to inactivity. If you are still facing this issue, please feel free to raise a support ticket with our team at support@braze.com. Thanks!