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

Bundles generated offline do not start running the RN app when executed (white screen on version 0.69+) #10255

Closed
AlenToma opened this issue Jul 12, 2022 · 15 comments · Fixed by #10298
Assignees
Labels
bug Developer First Experience Issues that are going to be hit by a new developer as they first try out RNW must-have p1 Recent Regression
Milestone

Comments

@AlenToma
Copy link

Problem Description

I have build an app base64string-package-maker to be able to decrypt packages so that I could use the package on other apps.

The problem is that When I build publish/create app Package with release as a target I only get blank app.

That mean when I run Install.ps1 the app gets installed but there is no js included what so ever.

I think that the app boundle is not included somehow or maybe something else.

I do not get Any exception or error, So I have no Idea what is happning.

Steps To Reproduce

1- create an app and then publish it with release
2- You will get a clean app without any js

OR

1- fork my app base64string-package-maker
2- publish it and see that there is no js included

Expected Results

The app should show the js components and run as normal.

CLI version

8.0.3

Environment

System:
    OS: Windows 10 10.0.19044
    CPU: (8) x64 Intel(R) Core(TM) i7-3820 CPU @ 3.60GHz
    Memory: 5.70 GB / 11.92 GB
  Binaries:
    Node: 14.18.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 6.14.15 - C:\Program Files\nodejs\npm.CMD
    Watchman: Not Found
  SDKs:
    Android SDK: Not Found
    Windows SDK:
      AllowDevelopmentWithoutDevLicense: Enabled
      AllowAllTrustedApps: Enabled
      Versions: 10.0.17763.0, 10.0.18362.0, 10.0.19041.0
  IDEs:
    Android Studio: AI-212.5712.43.2112.8609683
    Visual Studio: 16.11.32602.291 (Visual Studio Enterprise 2019)
  Languages:
    Java: 18.0.1.1 - C:\Program Files\Common Files\Oracle\Java\javapath\javac.EXE
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.0.0 => 18.0.0
    react-native: 0.69.1 => 0.69.1
    react-native-windows: 0.69.1 => 0.69.1
  npmGlobalPackages:
    *react-native*: Not Found

Target Platform Version

10.0.15063

Target Device(s)

Desktop

Visual Studio Version

Visual Studio 2019

Build Configuration

Release

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

base64string-package-maker

@AlenToma AlenToma added the bug label Jul 12, 2022
@ghost ghost added the Needs: Triage 🔍 New issue that needs to be reviewed by the issue management team (label applied by bot) label Jul 12, 2022
@AlenToma
Copy link
Author

Solved it by downgrading react-native to 0.67

@chrisglein
Copy link
Member

The link to base64string-package-maker doesn't work, is it a private repo?
Is your app C# or C++?

Through validating the publish of React Native Gallery on 0.69 we know that bundling for C++ in release is good.
The end to end test app should be validating this with tests that run release with the bundle. @jonthysell can you validate that is being covered here?

@chrisglein chrisglein added Recent Regression Area: C#/C++ interop and removed Needs: Triage 🔍 New issue that needs to be reviewed by the issue management team (label applied by bot) labels Jul 14, 2022
@chrisglein chrisglein added this to the 0.70 milestone Jul 14, 2022
@AlenToma
Copy link
Author

AlenToma commented Jul 14, 2022

I hade downgraded to 0.67.4 and it is working now so the repo work now and I changed it private.

The repo I create is cs with the latest react-native and latest react-native-windows.

So as long as you create one and publish it with a release, I am sure that you will get the same problem.

The only libraries I hade on top of react-native and react-native-windows are the following

    "crypto-js": "^3.1.9-1",
    "js-base64": "^3.7.2",
    "react-native-fs": "git+https://github.com/avmoroz/react-native-fs.git#dev",

@jonthysell
Copy link
Contributor

I can repro this on 0.69. The bundle file is present in the appx package, investigating to see why it isn't loading when the app starts.

@jonthysell
Copy link
Contributor

Confirmed that the bundle is seen and loaded from disk, still investigating.

@jonthysell
Copy link
Contributor

Confirmed that this repros with new 69 C++ apps in release mode too.

@jonthysell
Copy link
Contributor

Confirmed this issue does not repro in RNW 0.68.9.

This only repros in RNW 0.69.

@jonthysell jonthysell changed the title Creating a release package dose not load the js components Bundles generated offline do not start running the RN app code when executed Jul 18, 2022
@jonthysell jonthysell changed the title Bundles generated offline do not start running the RN app code when executed Bundles generated offline do not start running the RN app when executed Jul 18, 2022
@jonthysell
Copy link
Contributor

jonthysell commented Jul 18, 2022

Still actively investigating this, spent all day Friday trying to debug what's going on. So far:

  1. The JS bundle is being created successfully at build time.
  2. The bundle file is included in the appx
  3. The bundle file is loaded into memory when the native app starts
  4. The bundle's contents are passed off the the JS engine and executed without any errors thrown

However, the JS app doesn't start. As far as I can see, no messages are ever sent across the bridge, view managers never create any views, etc. Without any errors, you're left with an empty ReactRootControl and the JS code is "done".

This repros in debug with a local bundle (so it's not just release). It repros with both chakra and hermes. It repros with both dev=true or dev=false.

The only remaining lead is that it doesn't repro with the E2ETestApp, which loads a modified version of RNTesterApp. Which is double frustrating because the E2E tests actually interact with the UI, so if the issue did repro, the tests would have failed and caught this.

@jonthysell
Copy link
Contributor

I have confirmed via experiment that copying and using the "new RN app template" JS within the e2e test app source repros the behavior - loading bundle via metro works, loading offline bundle gives a blank app.

jonthysell added a commit to jonthysell/react-native-windows that referenced this issue Jul 21, 2022
…undles synchronously

`JsToNativeBridge::callNativeModules` only calls the stored `BridgeUIBatchInstanceCallback::onBatchComplete` if it's at the end of a batch, and either a native/turbo module method had been called previously, or if there are new incoming method calls. This call to `onBatchComplete` is what causes the batched UI queue to be processed, rendering changes in the native UI.

However, some (simple) JS apps, such as the default template for a new RN app, don't make any native function calls during app startup. When loading bundles asynchronously from Metro, the `onBatchComplete` call to process the UI queue gets posted to the native queue, so it gets run appropriately.

However, when loading bundles synchronously (from a pre-built bundle file), the first `onBatchComplete` will only be called if a native/turbo module was called during app startup. Without it, the app is *technically running*, but batched UI queue just sits there with the tasks to build the initial UI unprocessed.

The result is a "blank app", i.e. the `ReactRootView` has no children. "Technically" the app has loaded and is running (if you click we'll dispatch events to the JS side).

This PR fixes the issue by explictly calling the `onBatchComplete` after the app has loaded from a synchronous bundle load. If the batch has already been processed, then it's essentially a slightly wasteful no-op.

I have tested that this resolves the issue for the "simple" apps, and seems to have no adverse effect on apps that have already caused `onBatchComplete` to be called normally.

Resolves microsoft#10255
@jonthysell jonthysell added the Developer First Experience Issues that are going to be hit by a new developer as they first try out RNW label Jul 21, 2022
@jonthysell
Copy link
Contributor

The bug is that the commands to render the UI don't get processed on the native side if no native modules are ever called by the JS.

@chrisglein chrisglein pinned this issue Jul 25, 2022
@chrisglein chrisglein changed the title Bundles generated offline do not start running the RN app when executed Bundles generated offline do not start running the RN app when executed (white screen on version 0.69+) Jul 25, 2022
@taduyde
Copy link

taduyde commented Jul 26, 2022

the same problem, any update or any way to a workaround for this?

@taduyde
Copy link

taduyde commented Jul 26, 2022

Hi @jonthysell ,
the issue also happened on version: 0.67.2

@cjhines
Copy link

cjhines commented Aug 30, 2022

I'm still encountering this on 0.69.6, where I believe the fix was published.

Weirdly, when I build a package in Visual Studio the bug does not occur. This is still a blocker however, as it prevent our CI deployment.

@ghost ghost added the Needs: Attention 👋 An issue that had been tagged "Needs: Author Feedback" has received activity (label applied by bot) label Aug 30, 2022
@chrisglein chrisglein unpinned this issue Aug 30, 2022
@chrisglein
Copy link
Member

I'm still encountering this on 0.69.6, where I believe the fix was published.

Weirdly, when I build a package in Visual Studio the bug does not occur. This is still a blocker however, as it prevent our CI deployment.

This was only recently backported to 0.69. You're going to need something newer. The build published next week should have it (0.69.7).

@chrisglein chrisglein removed the Needs: Attention 👋 An issue that had been tagged "Needs: Author Feedback" has received activity (label applied by bot) label Sep 1, 2022
@noshaid-ali
Copy link

noshaid-ali commented Feb 26, 2025

I'm facing this blank white window error.
"react": "19.0.0",
"react-native": "^0.77.0",
"react-native-windows": "0.77.0"

Can anyone help me please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Developer First Experience Issues that are going to be hit by a new developer as they first try out RNW must-have p1 Recent Regression
Projects
None yet
6 participants