facebookarchive / react-native-fbsdk

A React Native wrapper around the Facebook SDKs for Android and iOS. Provides access to Facebook login, sharing, graph requests, app events etc.
https://developers.facebook.com/docs/react-native
Other
2.99k stars 908 forks source link

FBSDKSwizzler.m crash on iOS #661

Closed lucasroca closed 4 years ago

lucasroca commented 4 years ago

🐛 Bug Report

Our app latest version has been running without any issues for about 10 days now. Today the iOS app started crashing for many users on app launch. Log from crashlytics:

Crashed: com.apple.main-thread
EXC_BAD_ACCESS KERN_PROTECTION_FAILURE 0x000000016bcfbfc0
fb_findSwizzle

Crashed: com.apple.main-thread
0  libobjc.A.dylib                0x1b88d71b8 cache_fill + 138
1  libobjc.A.dylib                0x1b88e73b4 lookUpImpOrForward + 460
2  libobjc.A.dylib                0x1b88e7144 class_getInstanceMethod + 60
3  barrymobile                    0x1040b3858 fb_findSwizzle + 46 (FBSDKSwizzler.m:46)
4  barrymobile                    0x1040b32e0 fb_swizzledMethod_2 + 59 (FBSDKSwizzler.m:59)
5  barrymobile                    0x104289144 -[RCTTextView didMoveToWindow] + 177 (RCTTextView.m:177)
6  barrymobile                    0x1040b3310 fb_swizzledMethod_2 + 63 (FBSDKSwizzler.m:63)
7  UIKitCore                      0x1bd0402b0 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 723176
8  UIKitCore                      0x1bd03fe28 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 4375196432
9  UIKitCore                      0x1bd0341d4 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 723176
10 UIKitCore                      0x1bd0340bc -[UIView(Hierarchy) _postMovedFromSuperview:] + 4375196432
11 UIKitCore                      0x1bd0429c4 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 723176
12 barrymobile                    0x1042512cc -[UIView(React) didUpdateReactSubviews] + 174 (UIView+React.m:174)
13 barrymobile                    0x104247a54 -[RCTView didUpdateReactSubviews] + 569 (RCTView.m:569)
14 barrymobile                    0x10423e440 __48-[RCTUIManager _dispatchChildrenDidChangeEvents]_block_invoke + 1240 (RCTUIManager.m:1240)
15 barrymobile                    0x10423de30 __44-[RCTUIManager flushUIBlocksWithCompletion:]_block_invoke + 1163 (RCTUIManager.m:1163)
16 barrymobile                    0x10423df2c __44-[RCTUIManager flushUIBlocksWithCompletion:]_block_invoke.415 + 1187 (RCTUIManager.m:1187)
17 libdispatch.dylib              0x1b887d610 _dispatch_call_block_and_release + 723176
18 libdispatch.dylib              0x1b887e184 _dispatch_client_callout + 4375196432
19 libdispatch.dylib              0x1b886135c _dispatch_main_queue_callback_4CF$VARIANT$armv81 + 723176
20 CoreFoundation                 0x1b8b2e3c4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 4375196432
21 CoreFoundation                 0x1b8b293b8 __CFRunLoopRun + 723176
22 CoreFoundation                 0x1b8b288bc CFRunLoopRunSpecific + 4375196432
23 GraphicsServices               0x1c2994328 GSEventRunModal + 723176
24 UIKitCore                      0x1bcbbe6d4 UIApplicationMain + 4375196432
25 barrymobile                    0x1040115e4 main + 14 (main.m:14)
26 libdyld.dylib                  0x1b89b3460 start + 4375196432

Might be relevant: All crashes happened on iOS 13.

Expected Behavior

App not to crash. Looks like a workaround is changing from Live to Development mode in Facebook developers dashboard and re-installing the app. But of course that's not ideal.

Environment

I'm using react-native-fbsdk v1.0.4

System:
    OS: macOS Mojave 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
    Memory: 506.11 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.8.1 - /usr/local/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.11.3 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
  IDEs:
    Android Studio: 3.4 AI-183.5429.30.34.5452501
    Xcode: 10.3/10G8 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0 
    react-native: ^0.61.2 => 0.61.2 
  npmGlobalPackages:
    react-native-cli: 2.0.1
    react-native-git-upgrade: 0.2.7
chr4ss1 commented 4 years ago

not sure if it helps you, but make sure you have updated to latest react-native-fbsdk and also latest FB framework that supports ios13

more info at

https://github.com/facebook/react-native-fbsdk/issues/646 https://github.com/facebook/facebook-ios-sdk/releases

Also I would paste your code here as well.

lucasroca commented 4 years ago

Hi @ChrisEelmaa, I'm using react-native-fbsdk 1.0.4 and FB framework 5.7.0, that should be compatible according to the comments in #646. We are not using the Share nor Login APIs, just Analytics. Also, our production version was working fine until yesterday that suddenly started failing.

This is all the code we have related to fbsdk. Then we call this function in several places.

import { AppEventsLogger } from 'react-native-fbsdk';
...

export const trackScreen = name => {
    ...
        AppEventsLogger.logEvent(name);
    ...
};
gmertk commented 4 years ago

Hi @lucasroca, are you also using codeless events by any chance?

chloe-shin commented 4 years ago

dssfsdfsd

chloe-shin commented 4 years ago

hello

lucasroca commented 4 years ago

Hi @gmertk. Yes, we're using codeless events. Could that be an issue?

lucasroca commented 4 years ago

The past days the incidences decreased since the report date, but today 100% of our iOS users had this crash. I can't figure out how this dynamic crash rate is possible with the exact same client and no configuration changes.

crash report
bennom commented 4 years ago

@lucasroca We'd have exactly the same issue. But we figured by the date the app crashes started that we turned on the "advanced matching" feature in the Events Manager. This happened due to an incompatible versions. For the automatic matching feature you'll need Facebook SDK 5.8.0 and later:

Manual advanced matching for app is supported for Facebook Core SDK version 4.36 and later. Automatic advanced matching for app is supported for Facebook SDK version 5.8.0 and later.

But react-native-fbsdk 1.0.4 states 5.5 (see 1.0.4 commit).

Maybe this is also related to your issue and deactivating the feature in your Events Manager on Facebook also helps you. Fingers crossed! :)

lucasroca commented 4 years ago

@bennom That was exactly it! Thank you so much for the help

damontally commented 4 years ago

We experienced the exact same thing! Thank you for your help with this!!!

LuisRodriguezLD commented 4 years ago

Same here, thank you very much!

shereengh commented 3 years ago

@lucasroca We'd have exactly the same issue. But we figured by the date the app crashes started that we turned on the "advanced matching" feature in the Events Manager. This happened due to an incompatible versions. For the automatic matching feature you'll need Facebook SDK 5.8.0 and later:

Manual advanced matching for app is supported for Facebook Core SDK version 4.36 and later. Automatic advanced matching for app is supported for Facebook SDK version 5.8.0 and later.

But react-native-fbsdk 1.0.4 states 5.5 (see 1.0.4 commit).

Maybe this is also related to your issue and deactivating the feature in your Events Manager on Facebook also helps you. Fingers crossed! :)

This fixed it !!! Thank you