question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Couldn't call show() without a valid Activity

See original GitHub issue

Bug report

Summary

Occasionally (but rarely) I get this error due to react-native-bootsplash, causing the app to hang:

Error: Couldn't call show() without a valid Activity
  at anonymous(.../node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:103:promiseMethodWrapper)
  at o(.../node_modules/react-native-bootsplash/dist/commonjs/index.js:23:hide)

I am pretty sure that I have react-native-bootslpash configured as per instructions, as most of the times its works for me as intended (and when the problem happens, killing & restarting the app usually helps to get it loaded).

I suspect you might have some race condition in the code, leading to crash when in some rare cases the RN code is executed and RNBootslash .hide() is called before the bootslash is correctly loaded.

Environment info

react-native info output:

System:
    OS: Linux 5.4 Ubuntu 20.04.1 LTS (Focal Fossa)
    CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
    Memory: 973.41 MB / 11.60 GB
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 14.15.1 - ~/.nvm/versions/node/v14.15.1/bin/node
    Yarn: Not Found
    npm: 6.14.8 - ~/.nvm/versions/node/v14.15.1/bin/npm
    Watchman: Not Found
  SDKs:
    Android SDK: Not Found
  IDEs:
    Android Studio: Not Found
  Languages:
    Java: 11.0.9.1 - /usr/bin/javac
    Python: Not Found
  npmPackages:
    @react-native-community/cli: Not Found
    react: ^17.0.1 => 17.0.1 
    react-native: ^0.63.3 => 0.63.3 
  npmGlobalPackages:
    *react-native*: Not Found

Library version: 3.1.1

Steps to reproduce

I don’t have a realiable way to reproduce. The bug manifests itself randomly from time to time. In the nutshell I don’t do anything fancy: I have the bootslash installed as per instructions, when my React Native app starts it rapidly does some async initializations, and once they are ready it calls RNBootSplash.hide(..).

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:20 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
birdofpreyrucommented, Dec 7, 2020

@zoontek not quite, now when the issue happens, there is no error, but the splashscreen does not hide either, the .hide() call is just silently ignored.

In the meantime I found a way to reproduce it: if I deploy the app to device with short screen lock time, and by the moment the deployment is finished the screen is already locked, when I unlock the screen - the app is already open, and this problem is there. Also found a workaround: if instead calling .hide() when the app seems ready I just schedule the call 1 second after the root component rendering, it seems to work fine.

Probably you need to add some sort of async barrier: so that when .hide() is called it actually waits for a flag saying that the splash screen have been shown up already?

1reaction
lulmichalcommented, May 5, 2021

Hello everyone. I experience the same issue. When the screen is locked and the build (no matter if debug or release) is finished and I unlock the screen I see bootsplash. Then when I kill the app and open it again everything works as expected. It’s only happening after installation. To be precise it’s also happening for anyone who will download the app from Google Play “Internal testing”.

I did what @birdofpreyru said which is adding setTimeout in root component (App.js) render to execute .hide() after one second and now it works.

I’m sorry but I’m new to programming therefore if my help is required to somehow reproduce the issue or anything - you’ll need to be the most direct as possible 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

React-Native: Application has not been registered error
I guess it is an error caused by not matching name of project and your registered component. You have inited project with one...
Read more >
Invalid code signature problem with Xcode12 - Apple Developer
I-AM-RICH because it has an invalid code signature, inadequate entitlements or its profile has not been explicitly trusted by the user. User Info:...
Read more >
Troubleshooting | Search Ads 360 API - Google Developers
This error occurs if you haven't enabled the Search Ads 360 API for your account. Make sure you've done the following: Go to...
Read more >
Troubleshoot self-hosted integration runtime - Azure
This article explores common troubleshooting methods for self-hosted integration runtime (IR) in Azure Data Factory and Synapse workspaces.
Read more >
JNI tips | Android NDK
Calling AttachCurrentThread() on an already-attached thread is a no-op. Android does not suspend threads executing native code.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found