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 app works fine when using debug JS bundle, but has horrible bug in release JS bundle. #26078

Closed
Tochukwuibe opened this issue Aug 15, 2019 · 3 comments
Labels
Bug Platform: Android Android applications. Resolution: Locked This issue was locked by the bot. Tech: Bundler 📦 This issue is related to the bundler (Metro, Haul, etc) used.

Comments

@Tochukwuibe
Copy link

I'm getting ready to release my companies' app for internal beta testing. I noticed this issue when i tried to run a release build for my app by using android studio or running the commend: react-native run-android --variant=release.
What happens next is that my app then gets stuck on my initial loading screen (using react navigation for my app). It seems as though a certain portion of my app is not executing, which is the part where i am checking to see if the user is authenticated (using react-native-firebse) and then deciding whether to send them into the main page or the login screen.
This logic runs in a redux saga, where i use an event channel (a wrapper around the firebase onAuthStateChange realtime listener) to monitor the users auth status and route them as i mentioned above. Using Alerts i was able to isolate the exact part of the saga where for some reason it never resolves the async value of the onAuthStateChange listener. I have put a label above the line of code in question.

I have tested both the debug and release JS bundle using the command to generate an offline bundle, and I am certain that the issue is in the release bundle alone.

NOTE: At first i was having this issue with react-native 0.59.9 on Both Android and IOS platform. I decided to update to the latest version 0.60.5 hoping that it would fix it. Now I am only experiencing this on the Android platform.

React Native version:
System:
OS: macOS 10.14.6
CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
Memory: 2.07 GB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.16.2 - ~/.nvm/versions/node/v10.16.2/bin/node
npm: 6.9.0 - ~/.nvm/versions/node/v10.16.2/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
Android SDK:
API Levels: 27, 28, 29
Build Tools: 28.0.3, 29.0.2
System Images: android-27 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5692245
Xcode: 10.3/10G8 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.6 => 16.8.6
react-native: 0.60.5 => 0.60.5
npmGlobalPackages:
react-native-cli: 2.0.1

Steps To Reproduce

  1. Create app
  2. include firebase
  3. include redux saga
  4. Use event channel to listen for authstateChanges
  5. Create a release build of the app
  6. See bug.

Describe what you expected to happen:
The app should run fine like it does in debug mode.

Snack, code example, screenshot, or link to a repository:

function* checkAuthStatus() {
    try {


        const authChan = yield call(eventChannel$, AppAuthService.currentUser$);
        const navigation = yield call(getTopLevelNavigator);

        while (true) {

           // HERE IS THE LINE OF CODE THAT NEVER RESOLVES
            const { user } = yield take(authChan);  

            if (!!user) {

                const { claims } = yield call(AppAuthService.getIdTokenResult);
                yield put(AuthActions.userAuthenticated({ user, claims }));

                if (!user.emailVerified || !claims.v2Verified) {


                    navigation.navigate('Auth/Authenticate', { view: 'verify' })

                } else {

                    navigation.navigate('Tabs');
                }


            } else {
                navigation.navigate('Intro');

                yield put(AuthActions.userUnAuthenticated());
            }
        }
    } finally {

    }
}

@Tochukwuibe Tochukwuibe changed the title App works fine when using debug JS bundle, but has horrible bug in release JS bundle. Android app works fine when using debug JS bundle, but has horrible bug in release JS bundle. Aug 15, 2019
@Tochukwuibe
Copy link
Author

Ps, im pretty sure its not the fault of redux saga or react-native-firebase, because they both work fine in Android debug build and on IOS release build. However, I could be wrong.

@react-native-bot react-native-bot added Platform: Android Android applications. Tech: Bundler 📦 This issue is related to the bundler (Metro, Haul, etc) used. labels Aug 15, 2019
@kaloncheung124
Copy link

kaloncheung124 commented Aug 17, 2019

Have you tried disabling Hermes in your app/build.gradle? We had this same problem, and we didn't catch it until after it was deployed to Google Play. After some debugging, disabling Hermes fixed our issue.

Related issue: #25927

@Tochukwuibe
Copy link
Author

Tochukwuibe commented Aug 18, 2019

Hermes was never enabled. I found a hack around the issue, though I can't explain why it works. I was wrapping the firebase onAuthState change with an event channel, which is something that redux-saga provides for handling continuous asynchronous listeners. There was a line of code that i was using to emit the value returned by the firebase onAuthStateChange (similar to resolve in Promise). I had to wrap it in a set timeout set to 0 for it to work. like so:

function authChannel(){
  return eventChannel(emitter => {
       firebase.auth().onAuthStateChange(user => {

                // wont work in release build without settimeout
               setTimeout(() =>  emitter(user), 0)

        })
   })
}

@facebook facebook locked as resolved and limited conversation to collaborators Oct 4, 2021
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: Android Android applications. Resolution: Locked This issue was locked by the bot. Tech: Bundler 📦 This issue is related to the bundler (Metro, Haul, etc) used.
Projects
None yet
Development

No branches or pull requests

3 participants