flipper icon indicating copy to clipboard operation
flipper copied to clipboard

EXC_BAD_ACCESS on Expo React Native 0.64 iOS real device

Open maciej-lepb opened this issue 4 years ago • 33 comments
trafficstars

🐛 Bug Report

In an iOS React Native Expo project upgraded from React Native 0.63 to React Native 0.64 the application crashes with EXC_BAD_ACCESS in Flipper upon generating a certificate signing request.

Screenshot 2021-04-06 at 15 30 39

Podfile (anonymised project and target names)

platform :ios, '11.0'

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/react-native-unimodules/cocoapods.rb'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

project 'X',
  'A' => :debug,
  'B' => :debug

target 'X' do
  pod 'react-native-ffmpeg/audio-lts', :podspec => '../node_modules/react-native-ffmpeg/react-native-ffmpeg.podspec'
  use_unimodules!
  config = use_native_modules!

  use_react_native!(
    :path => config["reactNativePath"],
    :hermes_enabled => true
  )

  pod 'RNSVG', :path => '../node_modules/react-native-svg'

  use_flipper!({ 'Flipper' => '0.83.0' }, configurations: ['Debug', 'A', 'B', 'C', 'D', 'FanTest', 'E', 'F', 'G', 'H', 'I'])

  post_install do |installer|
    flipper_post_install(installer)
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
      end
    end
  end
end

AppDelegate.m

@import Firebase;
#import "AppDelegate.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <React/RCTLinkingManager.h>

#import <UMCore/UMModuleRegistry.h>
#import <UMReactNativeAdapter/UMNativeModulesProxy.h>
#import <UMReactNativeAdapter/UMModuleRegistryAdapter.h>
#import <EXSplashScreen/EXSplashScreenService.h>
#import <UMCore/UMModuleRegistryProvider.h>

#if DEBUG
#ifdef FB_SONARKIT_ENABLED
#if FB_SONARKIT_ENABLED
#import <FlipperKit/FlipperClient.h>
#import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h>
#import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
#import <FlipperKitReactPlugin/FlipperKitReactPlugin.h>
#import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
#import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>

static void InitializeFlipper(UIApplication* application) {
  FlipperClient* client = [FlipperClient sharedClient];
  SKDescriptorMapper* layoutDescriptorMapper =
      [[SKDescriptorMapper alloc] initWithDefaults];
  [client addPlugin:[[FlipperKitLayoutPlugin alloc]
                            initWithRootNode:application
                        withDescriptorMapper:layoutDescriptorMapper]];
  [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]];
  [client addPlugin:[FlipperKitReactPlugin new]];
  [client addPlugin:[[FlipperKitNetworkPlugin alloc]
                        initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
  [client start];
}
#endif
#endif
#endif

@interface AppDelegate () <RCTBridgeDelegate>

@property (nonatomic, strong) UMModuleRegistryAdapter *moduleRegistryAdapter;
@property (nonatomic, strong) NSDictionary *launchOptions;

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  #if DEBUG
  #ifdef FB_SONARKIT_ENABLED
  #if FB_SONARKIT_ENABLED
  InitializeFlipper(application);
  #endif
  #endif
  #endif

  [FIRApp configure];

  self.moduleRegistryAdapter = [[UMModuleRegistryAdapter alloc] initWithModuleRegistryProvider:[[UMModuleRegistryProvider alloc] init]];
  self.launchOptions = launchOptions;
  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  #ifdef DEBUG
    [self initializeReactNativeApp];
  #else
    EXUpdatesAppController *controller = [EXUpdatesAppController sharedInstance];
    controller.delegate = self;
    [controller startAndShowLaunchScreen:self.window];
  #endif

  [super application:application didFinishLaunchingWithOptions:launchOptions];

  return YES;
}

- (RCTBridge *)initializeReactNativeApp
{
  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:self.launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"main" initialProperties:nil];
  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];

  return bridge;
 }

- (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge
{
  NSArray<id<RCTBridgeModule>> *extraModules = [_moduleRegistryAdapter extraModulesForBridge:bridge];
  // If you'd like to export some custom RCTBridgeModules that are not Expo modules, add them here!
  return extraModules;
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
 #ifdef DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
 #else
  return [[EXUpdatesAppController sharedInstance] launchAssetUrl];
 #endif
}

- (void)appController:(EXUpdatesAppController *)appController didStartWithSuccess:(BOOL)success {
  appController.bridge = [self initializeReactNativeApp];
  EXSplashScreenService *splashScreenService = (EXSplashScreenService *)[UMModuleRegistryProvider getSingletonModuleForClass:[EXSplashScreenService class]];
  [splashScreenService showSplashScreenFor:self.window.rootViewController];
}

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url
            options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
  return [RCTLinkingManager application:app openURL:url options:options];
}

- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity
 restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
{
 return [RCTLinkingManager application:application
                  continueUserActivity:userActivity
                    restorationHandler:restorationHandler];
}

@end

Environment

iPhone 12 Pro Max, actual device, iOS 14.4.2 (18D70), debug build

maciej-lepb avatar Apr 06 '21 13:04 maciej-lepb

cc @jknoxville does this ring a bell? @maciej-lepb could you provide a reproducible setup?

mweststrate avatar Apr 06 '21 14:04 mweststrate

@mweststrate will try ASAP, I know it's hard to debug without it, although stripping down our current project may take some time. Either way - I'll do my best. Thanks!

maciej-lepb avatar Apr 06 '21 14:04 maciej-lepb

Got the same problem.Happened on a generic iOS app.Do you have your own openssl lib in your app?

ma125125t avatar Apr 08 '21 09:04 ma125125t

Hi @maciej-lepb ,did you get any progress?

ma125125t avatar Apr 12 '21 03:04 ma125125t

@FFFang I started working on a stripped-down project to demo the issue. Not finished yet, I'll keep you posted. I guess not much that can be done without a demo project, right? Thanks!

maciej-lepb avatar Apr 12 '21 11:04 maciej-lepb

@maciej-lepb In my case,it is a conflict problem with OpenSSL.xcframework and libssl.a.I have fixed it.

ma125125t avatar Apr 14 '21 07:04 ma125125t

@FFFang I would like if you can explain how did you find that you have a conflict? and how did you fixed it? Thanks

RebeccaAouizerats avatar Apr 14 '21 11:04 RebeccaAouizerats

@RebeccaAouizerats check if there is another libssl lib in you project.If there is ,then strip it to use flipper's openssl.

ma125125t avatar Apr 15 '21 11:04 ma125125t

@FFFang Thanks you, you helped me to think on another direction. Indeed, I have a dependency, that use a framework, that use openssl. When removing the dependency the problem disappear. I have not yet been able to resolve the issue (also by adding openssl to the pod of the dependecy)

RebeccaAouizerats avatar Apr 20 '21 09:04 RebeccaAouizerats

mark. the same error.

xclidongbo avatar May 25 '21 04:05 xclidongbo

mark. the same error.

xclidongbo avatar May 25 '21 06:05 xclidongbo

@RebeccaAouizerats check if there is another libssl lib in you project.If there is ,then strip it to use flipper's openssl.

搞定了? 我也遇到这个问题了. 能否请教下怎么解决的?

xclidongbo avatar May 25 '21 06:05 xclidongbo

@RebeccaAouizerats check if there is another libssl lib in you project.If there is ,then strip it to use flipper's openssl.

搞定了? 我也遇到这个问题了. 能否请教下怎么解决的?

@xclidongbo 嗯,flipper用的openssl是最新版本的,如果你项目中本身有openssl,且是年代比较久远的,这两个库是不兼容的。解决方法就是修改podspec来修改依赖,在主项目中指定版本,我的情况,是用'1.0.2.20'版本的'OpenSSL-Universal'。

ma125125t avatar May 30 '21 02:05 ma125125t

@RebeccaAouizerats check if there is another libssl lib in you project.If there is ,then strip it to use flipper's openssl.

搞定了? 我也遇到这个问题了. 能否请教下怎么解决的?

@xclidongbo 嗯,flipper用的openssl是最新版本的,如果你项目中本身有openssl,且是年代比较久远的,这两个库是不兼容的。解决方法就是修改podspec来修改依赖,在主项目中指定版本,我的情况,是用'1.0.2.20'版本的'OpenSSL-Universal'。

尝试调低OpenSSL的版本号, 不过没啥用, 改了cache中的podspec文件, 但还是安装高版本的.

xclidongbo avatar Jun 06 '21 02:06 xclidongbo

用本地podspec.json试下

  pod 'Flipper-Folly', :podspec => 'Specs/Flipper/Flipper-Folly.podspec.json'
{
  "name": "Flipper-Folly",
  "version": "2.5.3",
  "license": {
    "type": "Apache License, Version 2.0"
  },
  "homepage": "https://github.com/facebook/folly",
  "summary": "An open-source C++ library developed and used at Facebook.",
  "authors": "Facebook",
  "source": {
    "git": "https://github.com/priteshrnandgaonkar/folly.git",
    "tag": "v2020.04.06.01"
  },
  "module_name": "folly",
  "dependencies": {
    "boost-for-react-native": [

    ],
    "Flipper-Glog": [

    ],
    "Flipper-DoubleConversion": [

    ],
    "OpenSSL-Universal": [
      "1.0.2.20"
    ],
    "libevent": [
      "~> 2.1.12"
    ]
  },
  "compiler_flags": "-DFOLLY_HAVE_PTHREAD=1 -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_LIBGFLAGS=0 -DFOLLY_HAVE_LIBJEMALLOC=0 -DFOLLY_HAVE_PREADV=0 -DFOLLY_HAVE_PWRITEV=0 -DFOLLY_HAVE_TFO=0 -DFOLLY_USE_SYMBOLIZER=0\n    -frtti\n    -fexceptions\n    -std=c++14\n    -Wno-error\n    -Wno-unused-local-typedefs\n    -Wno-unused-variable\n    -Wno-sign-compare\n    -Wno-comment\n    -Wno-return-type\n    -Wno-global-constructors",
  "source_files": [
    "folly/*.h",
    "folly/concurrency/*.h",
    "folly/container/*.h",
    "folly/container/detail/*.h",
    "folly/detail/*.h",
    "folly/executors/**/*.h",
    "folly/experimental/*.h",
    "folly/functional/*.h",
    "folly/futures/*.h",
    "folly/futures/detail/*.h",
    "folly/gen/*.h",
    "folly/hash/*.h",
    "folly/hash/detail/*.h",
    "folly/init/*.h",
    "folly/io/*.h",
    "folly/io/async/*.h",
    "folly/io/async/ssl/*.h",
    "folly/lang/*.h",
    "folly/memory/*.h",
    "folly/memory/detail/*.h",
    "folly/net/*.h",
    "folly/net/detail/*.h",
    "folly/portability/*.h",
    "folly/ssl/*.h",
    "folly/ssl/detail/*.h",
    "folly/synchronization/*.h",
    "folly/synchronization/detail/*.h",
    "folly/system/*.h",
    "folly/tracing/*.h",
    "folly/chrono/*.h",
    "folly/*.cpp",
    "folly/concurrency/*.cpp",
    "folly/container/detail/*.cpp",
    "folly/detail/*.cpp",
    "folly/executors/*.cpp",
    "folly/experimental/hazptr/*.cpp",
    "folly/futures/*.cpp",
    "folly/futures/detail/*.cpp",
    "folly/hash/*.cpp",
    "folly/io/*.cpp",
    "folly/io/async/*.cpp",
    "folly/io/async/ssl/*.cpp",
    "folly/lang/*.cpp",
    "folly/memory/*.cpp",
    "folly/memory/detail/*.cpp",
    "folly/net/*.cpp",
    "folly/portability/*.cpp",
    "folly/ssl/*.cpp",
    "folly/ssl/detail/*.cpp",
    "folly/String.cpp",
    "folly/synchronization/*.cpp",
    "folly/system/*.cpp"
  ],
  "exclude_files": [
    "folly/synchronization/Rcu.cpp",
    "folly/synchronization/Rcu.h"
  ],
  "header_mappings_dir": "folly",
  "header_dir": "folly",
  "libraries": "stdc++",
  "public_header_files": "folly/**/*.h",
  "pod_target_xcconfig": {
    "USE_HEADERMAP": "NO",
    "CLANG_CXX_LANGUAGE_STANDARD": "c++11",
    "HEADER_SEARCH_PATHS": "\"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/Flipper-DoubleConversion\" \"$(PODS_ROOT)/libevent/include\""
  },
  "platforms": {
    "ios": "10.0"
  }
}

ma125125t avatar Jun 07 '21 02:06 ma125125t

1.0.2.20

没用... 提示有多个依赖

[!] There are multiple dependencies with different sources for `Flipper-Folly` in `Podfile`:

- Flipper-Folly (from `FlipperProject/Thirds/Flipper-Folly/Flipper-Folly.podspec.json`)
- Flipper-Folly (~> 2.2)

xclidongbo avatar Jun 08 '21 03:06 xclidongbo

我尝试下把所有的Flipper 都放到本地试试

xclidongbo avatar Jun 08 '21 03:06 xclidongbo

I have the same problem.

The app crashes either when:

  • The app is already running and then I open Flipper
  • Flipper is already open and then I start the app

Sometimes I manage to successfully run Flipper and the app, but it is a rare occasion and it breaks as soon as I restart one of the two.

I'm using React Native 0.63.4. The issue appeared when trying to upgrade Flipper from 0.69 to 0.70 (it manifests even with newer versions).

zuccha avatar Jun 11 '21 15:06 zuccha

@xclidongbo

Hi,最后解决了这个问题了吗?

leejunhui avatar Jul 09 '21 02:07 leejunhui

@xclidongbo

Hi,最后解决了这个问题了吗?

没有, 我把flipper 去掉了. 用android调试, ios只用来打包.

xclidongbo avatar Jul 29 '21 03:07 xclidongbo

Same issue here 🙁

mpatafio avatar Sep 01 '21 11:09 mpatafio

@lblasa any idea what could go wrong here?

mweststrate avatar Sep 14 '21 10:09 mweststrate

I get reports about this crash from my production app. Far and away my most frequent crash report...but as far as I can tell it's happening when the app is in the background...

marcshilling avatar Oct 01 '21 01:10 marcshilling

Im facing this issue on react native 0.66.2 on a simulator or device! Any idea how to resolve it without commenting use_flipper!() ?

YahiaJabeur avatar Jan 01 '22 21:01 YahiaJabeur

Same issue here. React Native 0.63.4. use_flipper!({ 'Flipper' => '0.79.0' })

ybwdaisy avatar Feb 18 '22 10:02 ybwdaisy

try to update Flipper to 0.135.0 or 0.136.0

petpwiuta avatar Mar 02 '22 09:03 petpwiuta

@ma125125t 你好,我通过你说的方式进行了尝试,Xcode Run 起来之后真机没有 crash 掉了,但是 Flipper 打开后报了如下的错误:

image

请问你有遇到过吗

leejunhui avatar Mar 10 '22 09:03 leejunhui

Same issue here. React Native 0.63.4. use_flipper!({ 'Flipper' => '0.79.0' })

For me, is third-party library NIMSDK cause crashes, just remove it work for me.

ybwdaisy avatar Mar 10 '22 09:03 ybwdaisy

这是因为idb工具有问题,导致无法建立成功的通信,可以参考 https://github.com/facebook/idb/issues/659 里的解决方案。

ma125125t avatar Mar 10 '22 09:03 ma125125t

这是因为idb工具有问题,导致无法建立成功的通信,可以参考 facebook/idb#659 里的解决方案。

按照 issue 里面的指引,手动升级了 fb-idb,但是貌似 Flipper 还是不能识别 iOS 真机😂,安卓的真机没啥问题,看来只能先用着模拟器了

leejunhui avatar Mar 11 '22 09:03 leejunhui