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][Redbox Message] Misleading redbox message when starting app for the first time without packager running. #4739

Closed
qbig opened this issue Dec 12, 2015 · 16 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@qbig
Copy link
Contributor

qbig commented Dec 12, 2015

screen shot 2015-12-12 at 3 52 12 pm

The first time you run(accidentally) RN app without the packager running, the redbox would show the above message. Only after clicking 'reload' the info below would be shown, which is a lot more helpful?

screen shot 2015-12-12 at 3 52 22 pm

I am not sure but should we use the second redbox info for both cases ?

@facebook-github-bot
Copy link
Contributor

Hey qbig, thanks for reporting this issue!

React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.

  • If this is a feature request or a bug that you would like to be fixed by the team, please report it on Product Pains. It has a ranking feature that lets us focus on the most important issues the community is experiencing.
  • If you don't know how to do something or not sure whether some behavior is expected or a bug, please ask on StackOverflow with the tag react-native or for more real time interactions, ask on Discord in the #react-native channel.
  • We welcome clear issues and PRs that are ready for in-depth discussion; thank you for your contributions!

@qbig
Copy link
Contributor Author

qbig commented Dec 12, 2015

 private void recreateReactContextInBackgroundInner() {
    UiThreadUtil.assertOnUiThread();

    if (mUseDeveloperSupport && mJSMainModuleName != null) {
      if (mDevSupportManager.hasUpToDateJSBundleInCache()) {
        // If there is a up-to-date bundle downloaded from server, always use that
        onJSBundleLoadedFromServer();
      } else if (mJSBundleFile == null) {
        mDevSupportManager.handleReloadJS();
      } else {
        mDevSupportManager.isPackagerRunning(
            new DevServerHelper.PackagerStatusCallback() {
              @Override
              public void onPackagerStatusFetched(final boolean packagerIsRunning) {
                UiThreadUtil.runOnUiThread(
                    new Runnable() {
                      @Override
                      public void run() {
                        if (packagerIsRunning) {
                          mDevSupportManager.handleReloadJS();  
                        } else {
                          recreateReactContextInBackgroundFromBundleFile(); // <-- First time run would end up here
                        }
                      }
                    });
              }
            });
      }
      return;
    }

    recreateReactContextInBackgroundFromBundleFile();
  }

if reload is clicked,

                          mDevSupportManager.handleReloadJS();  

would get executed and show the correct the redbox info.

Seems this is the problem ?

                        if (packagerIsRunning) {
                          mDevSupportManager.handleReloadJS();  
                        } else {
                          recreateReactContextInBackgroundFromBundleFile(); // <-- First time run would end up here
                        }

@mkonicek

@ippa
Copy link

ippa commented Dec 12, 2015

Also, why not spell it out to new users "Please run 'react-native start' in the root of your project and make sure your device is connected"?

We all know people hate reading long intros ("what is the developmentserver?") and often just starts playing around with new stuff :).

Maybe even mention "adb reverse tcp:8081 tcp:8081" if android is detected.. not sure about this one.

@arypurnomoz
Copy link

is there anyway to solve this problem?

@satya164
Copy link
Contributor

PRs are welcome for a better error message.

@qbig
Copy link
Contributor Author

qbig commented Dec 27, 2015

screen shot 2015-12-28 at 12 14 56 am

The root of the issue is that we are calling 'runJSBundle' when there isn't one. And the native cpp implementation throw back the wrong error message. Can fix this in cpp land. But I was struggling getting jni debugging working. Or alternatively, we can check the validity of the bundle before calling 'runJSBundle', which is what I tried in #4738

Any suggestions would be great @satya164 @mkonicek

@mkonicek
Copy link
Contributor

mkonicek commented Jan 6, 2016

Can we simply replace both error messages with the message iOS has?

screen shot 2016-01-06 at 2 26 40 pm

IMHO "Can't find variable __fbBatchedBridge" is never useful to anyone. If you can't replace the message in C++, can you detect that exception reliably and throw one with a better message?

The "Unable to download JS bundle" message is not very good either. Replacing that with the clear message should be trivial.

Thanks so much for working on this, the cryptic message has been bothering many people for a long time.

@kmagiera, @foghina What do you think?

@kmagiera
Copy link
Contributor

kmagiera commented Jan 6, 2016

We used to have a better error message for this case. This looks like a regression then. But yeah, the one on iOS is even better, so let's go with that

@philikon
Copy link
Contributor

philikon commented Jan 8, 2016

As of 0.18.0rc, the __fbBatchedBridge error message is now also the one shown on iOS. Seems like a regression on both platforms.

@mkonicek
Copy link
Contributor

Yeah this is pretty bad. Anyone up for sending a fix?

@satya164
Copy link
Contributor

Not sure if this is the correct way, but here is a PR - #5235

@satya164
Copy link
Contributor

@mkonicek Can you cc someone who has more context on this?

@foghina
Copy link
Contributor

foghina commented Jan 20, 2016

Is this still happening on 0.18?

@satya164
Copy link
Contributor

@foghina Yes, happens on master!

@jsierles
Copy link
Contributor

Just wanted to chime in here. #5235 improved the message related to the packager not running. However, the __fbBatchedBridge error still pops up in two cases:

  • when adb reverse hasn't been setup yet for android devices (common enough)
  • when a build tries to load a non-existent main.jsbundle (happens if you want to run a debug build with a jsbundle)

Any suggestions for making sure these two cases are covered as well?

@mkonicek
Copy link
Contributor

Hi there! This issue is being closed because it has been inactive for a while.

But don't worry, it will live on with ProductPains! Check out its new home: https://productpains.com/post/react-native/androidredbox-message-misleading-redbox-message-when-starting-app-for-the-first-time-without-packager-running

ProductPains helps the community prioritize the most important issues thanks to its voting feature.
It is easy to use - just login with GitHub. GitHub issues have voting too, nevertheless
Product Pains has been very useful in highlighting the top bugs and feature requests:
https://productpains.com/product/react-native?tab=top

Also, if this issue is a bug, please consider sending a pull request with a fix.
We're a small team and rely on the community for bug fixes of issues that don't affect fb apps.

@facebook facebook locked as resolved and limited conversation to collaborators Jul 20, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 20, 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