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

Rendering to fast? #226

Open
1 of 3 tasks
ThorvaldAagaard opened this issue Jul 5, 2019 · 1 comment
Open
1 of 3 tasks

Rendering to fast? #226

ThorvaldAagaard opened this issue Jul 5, 2019 · 1 comment

Comments

@ThorvaldAagaard
Copy link

Bug Report

It looks like the code is executed to fast, when running in a browser, so when the show-function is called, then document.body is still null, thus giving a javascript error

Problem

No splashscreen

What is expected to happen?

Splashscreen should be shown in browser

What does actually happen?

document.body.appendChild(localSplash); returns exception as document.body is still null

Information

Just waiting 200 ms before appending the splashscreen, like this

        window.setTimeout(function () {
            if (document.body) {
                document.body.appendChild(localSplash);
            }
        }, 200);

seems to fix the problem

Another idea might also be to make the hide more robust by adding a check before removing the child like this

        window.setTimeout(function () {
            console.log("Removing splash: " + innerLocalSplash);
            if (innerLocalSplash && innerLocalSplash.parentNode == document.body) {
                document.body.removeChild(innerLocalSplash);
            }
            innerLocalSplash = null;
        }, 1000);

Command or Code

Requires a fast computer, and I have seen it on the latest version of Chrome

Environment, Platform, Device

Chrome

Version information

Using cordova-plugin-splashscreen 5.0.3

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
@piwel
Copy link

piwel commented May 20, 2021

Thanks for your help, I have the exact same problem and it looks your first fix works.

Also, I would recommend using innerLocalSplash.remove() instead of document.body.removeChild(innerLocalSplash); to deal with edge cases, e.g. usage in Chrome Extension that might create multiple bodies when you close and open it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants