facebook / flipper

A desktop debugging platform for mobile developers.
https://fbflipper.com/
MIT License
13.35k stars 956 forks source link

EXC_BAD_ACCESS on Expo React Native 0.64 iOS real device #2167

Open maciej-lepb opened 3 years ago

maciej-lepb commented 3 years ago

🐛 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

mweststrate commented 3 years ago

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

maciej-lepb commented 3 years ago

@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!

ma125125t commented 3 years ago

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

ma125125t commented 3 years ago

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

maciej-lepb commented 3 years ago

@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!

ma125125t commented 3 years ago

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

RebeccaAouizerats commented 3 years ago

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

ma125125t commented 3 years ago

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

RebeccaAouizerats commented 3 years ago

@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)

xclidongbo commented 3 years ago

mark. the same error.

xclidongbo commented 3 years ago

mark. the same error.

xclidongbo commented 3 years ago

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

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

ma125125t commented 3 years ago

@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'。

xclidongbo commented 3 years ago

@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文件, 但还是安装高版本的.

ma125125t commented 3 years ago

用本地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"
  }
}
xclidongbo commented 3 years ago

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 commented 3 years ago

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

zuccha commented 3 years ago

I have the same problem.

The app crashes either when:

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).

leejunhui commented 3 years ago

@xclidongbo

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

xclidongbo commented 3 years ago

@xclidongbo

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

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

mpatafio commented 3 years ago

Same issue here 🙁

mweststrate commented 3 years ago

@lblasa any idea what could go wrong here?

marcshilling commented 3 years ago

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...

YahiaJabeur commented 2 years ago

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!() ?

ybwdaisy commented 2 years ago

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

petpwiuta commented 2 years ago

try to update Flipper to 0.135.0 or 0.136.0

leejunhui commented 2 years ago

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

image

请问你有遇到过吗

ybwdaisy commented 2 years ago

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.

ma125125t commented 2 years ago

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

leejunhui commented 2 years ago

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

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

OneHatRepo commented 2 years ago

Seeing this on Expo SDK 45, react-native 0.68.2, iOS simulator. Not seeing it on real device.

davidascholer commented 1 year ago

Thought I would comment so this issue didn't get stale. I just ran into this issue after another developer integrated Flipper into our project. After pod deintegrate, I noticed some packages that had been uninstalled and not reinstalled with pod install. After that, I was having clean builds. Not a permanent solution, but it's what unblocked me. For now, at least 🤞

XCode 14.2 React Native v0.70.2 Tested on 3 devices w the same issue/resolve: Ipad Pro 1st gen -Ipad 16.2 Ipad Mini 5th gen -Ipad 16.2 Iphone 7 - IOS 15.4

chirag-blueed commented 5 months ago

did anyone find a proper fix for this issue?