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

Android crashes when any form of ScrollView exists in signed production build "app-release.apk" #17358

Closed
cyphire opened this issue Dec 26, 2017 · 4 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@cyphire
Copy link

cyphire commented Dec 26, 2017

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

Environment:
OS: Windows 10
Node: 8.9.1
Yarn: 1.3.2
npm: 5.5.1
Watchman: Not Found
Xcode: N/A
Android Studio: Version 3.0.0.0 AI-171.4408382

Packages: (wanted => installed)
react: 16.0.0 => 16.0.0
react-native: 0.51.0 => 0.51.0

Steps to Reproduce

  1. When building the app in normal debug mode, no issue.
  2. Created a dummy certificate and updated the build.gradle correctly, In the "android" directory, I ran "gradlew assembleRelease".
  3. This created the correct SIGNED app-release.apk in the apk directory.
  4. Installed the app-release.apk in both the emulator on computer as well as an LG V20 device.
  5. Both the emulator and the device crash on startup.
  6. Other person with same issue:
    GitHub issue 353891887

Expected Behavior

I expected that the release version would work as the debug version did.

Actual Behavior

Signed apk crashes when any screen which has any version of ScrollView in it's render.

The problem is this:
this._subscribableSubscriptions.forEach
fails because the "this._subscribableSubscriptions" is null (and should not be).

Here is where the error occurs: in Subscribable.js
(..\node_modules\react-native\Libraries\Components\Subscribable.js)

This is the original code.

  componentWillUnmount: function() {
    this._subscribableSubscriptions.forEach(
      (subscription) => subscription.remove()
    );
    this._subscribableSubscriptions = null;
  },

Here is where i removed the failing call. I have confirmed that this._subscribableSubscriptions returns a null and crashes when the forEach() is called.

  componentWillUnmount: function() {
  console.log(`Subscribable - error location? ${this._subscribableSubscriptions}`)  
  if (false) {
    this._subscribableSubscriptions.forEach(
      (subscription) => subscription.remove()
    );
  }
    this._subscribableSubscriptions = null;
  },

Following removing the offending code, the app no longer crashes on startup.

FROM LOGCAT:

12-26 16:02:51.675 20609 20609 D ReactNative: ReactInstanceManager.ctor()
12-26 16:02:51.678 20609 20609 D ReactNative: ReactInstanceManager.createReactContextInBackground()
12-26 16:02:51.678 20609 20609 D ReactNative: ReactInstanceManager.recreateReactContextInBackgroundInner()
12-26 16:02:51.679 20609 20609 D ReactNative: ReactInstanceManager.recreateReactContextInBackgroundFromBundleLoader()
12-26 16:02:51.679 20609 20609 D ReactNative: ReactInstanceManager.recreateReactContextInBackground()
12-26 16:02:51.679 20609 20609 D ReactNative: ReactInstanceManager.runCreateReactContextOnNewThread()
12-26 16:02:51.721 20609 20625 D ReactNative: ReactInstanceManager.createReactContext()
12-26 16:02:51.783 20609 20625 D ReactNative: Initializing React Xplat Bridge.
12-26 16:02:51.784 20609 20625 D ReactNative: Initializing React Xplat Bridge before initializeBridge
12-26 16:02:51.789 20609 20625 D ReactNative: Initializing React Xplat Bridge after initializeBridge
12-26 16:02:51.789 20609 20625 D ReactNative: CatalystInstanceImpl.runJSBundle()
12-26 16:02:51.807 20609 20633 D ReactNative: ReactInstanceManager.setupReactContext()
12-26 16:02:51.807 20609 20633 D ReactNative: CatalystInstanceImpl.initialize()
12-26 16:02:51.812 20609 20633 D ReactNative: ReactInstanceManager.attachRootViewToInstance()
12-26 16:02:51.940 20609 20632 I ReactNativeJS: Running application "test" with appParams: {"rootTag":1}. __DEV__ === false, development-level warning are OFF, performance optimizations are ON
12-26 16:02:51.965 20609 20632 E ReactNativeJS: TypeError: undefined is not an object (evaluating 'this._subscribableSubscriptions.forEach')
12-26 16:02:51.965 20609 20632 E ReactNativeJS:
12-26 16:02:51.965 20609 20632 E ReactNativeJS: This error is located at:
12-26 16:02:51.965 20609 20632 E ReactNativeJS:     in ScrollView
12-26 16:02:51.965 20609 20632 E ReactNativeJS:     in t
12-26 16:02:51.965 20609 20632 E ReactNativeJS:     in t
12-26 16:02:51.965 20609 20632 E ReactNativeJS:     in RCTView
12-26 16:02:51.965 20609 20632 E ReactNativeJS:     in t
12-26 16:02:51.965 20609 20632 E ReactNativeJS:     in RCTView
12-26 16:02:51.965 20609 20632 E ReactNativeJS:     in RCTView
12-26 16:02:51.965 20609 20632 E ReactNativeJS:     in t
12-26 16:02:51.969 20609 20632 E ReactNativeJS: TypeError: undefined is not an object (evaluating 'this._subscribableSubscriptions.forEach')
12-26 16:02:51.969 20609 20632 E ReactNativeJS:
12-26 16:02:51.969 20609 20632 E ReactNativeJS: This error is located at:
12-26 16:02:51.969 20609 20632 E ReactNativeJS:     in ScrollView
12-26 16:02:51.969 20609 20632 E ReactNativeJS:     in t
12-26 16:02:51.969 20609 20632 E ReactNativeJS:     in t
12-26 16:02:51.969 20609 20632 E ReactNativeJS:     in RCTView
12-26 16:02:51.969 20609 20632 E ReactNativeJS:     in t
12-26 16:02:51.969 20609 20632 E ReactNativeJS:     in RCTView
12-26 16:02:51.969 20609 20632 E ReactNativeJS:     in RCTView
12-26 16:02:51.969 20609 20632 E ReactNativeJS:     in t
12-26 16:02:52.418 20609 20609 D ReactNative: ReactInstanceManager.detachViewFromInstance()

Reproducible Demo

Because the app crashes on a production build here is a simple App.js file.

This demo can be reproduced by:

  1. creating a new: react-native init test
  2. substituting the App.js code below for the App.js which is the default on creating a project.
  3. follow instructions for creating a keystore
  4. updating the gradle.build as per the instructions in react-native docs.
  5. build in the android directory with "gradlew assembleRelease"
  6. run and see that with version 51.0 crashes in the Scribbable.js (as show above) although, of course, it's not Scribbable wher the error is, that is just where it occurs.

NOTE: but probably not important. When I build my app (either my own app or the test app), I must run gradlew assembleRelease twice, it always fails the first time. I think it needs to reset the transform cache.

ADDITIONAL NOTE: From what the other person who has seen this said, when reducing the version of React-native to 49.5 the problem goes away.

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from 'react';
import {
  Platform,
  FlatList,
  StyleSheet,
  Text,
  View
} from 'react-native';

const instructions = Platform.select({
  ios: 'Press Cmd+R to reload,\n' +
    'Cmd+D or shake for dev menu',
  android: 'Double tap R on your keyboard to reload,\n' +
    'Shake or press menu button for dev menu',
});

export default class Example extends Component<{}> {
  render() {
    return (
      <View style={styles.container}>
        <FlatList
          data={[{key: 0, title: 'Hello1'}, {key: 1, title: 'Hello2'}, {key: 2, title: 'Hello3'}]}
          renderItem={(itm)=> {
            return (<View key={itm.item.key}><Text>{itm.item.title}</Text></View>)
          }}
        />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});

@maciekstosio
Copy link

I've got same thing on iOS on react-native 0.48.3, and actually suddenly I have bunch of warning at the beginning

2017-12-26 22:46:10.139 [info][tid:main][RCTCxxBridge.mm:213] Initializing <RCTCxxBridge: 0x6000003c1b30> (parent: <RCTBridge: 0x6080000d2050>, executor: (null))
2017-12-26 22:46:10.186 [warn][tid:main][RCTBridge.m:121] Class RCTCxxModule was not exported. Did you forget to use RCT_EXPORT_MODULE()?
2017-12-26 22:46:10.202 [warn][tid:main][RCTModuleData.mm:69] Module RNCrashes requires main queue setup since it overrides `constantsToExport` but doesn't implement `requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
2017-12-26 22:46:10.202 [warn][tid:main][RCTModuleData.mm:69] Module RCTCameraManager requires main queue setup since it overrides `constantsToExport` but doesn't implement `requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
2017-12-26 22:46:10.202 [warn][tid:main][RCTModuleData.mm:69] Module CodePush requires main queue setup since it overrides `constantsToExport` but doesn't implement `requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
...

@cyphire
Copy link
Author

cyphire commented Dec 26, 2017

I think your issue goes back to the previous thread you were on.... Not this bug.

@maciekstosio
Copy link

maciekstosio commented Dec 26, 2017

I've got the same error as you on production build, but at the same time these errors appear on development build. I don't know if it's related.
Yours sounds to be duplicated with #17348

@cyphire
Copy link
Author

cyphire commented Dec 27, 2017

Closing issue for

I am closing the issue I created today for this one.

#17348

@cyphire cyphire closed this as completed Dec 27, 2017
@facebook facebook locked as resolved and limited conversation to collaborators Dec 27, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Dec 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

3 participants