apache / apache/cordova-plugin-splashscreen

Rendering to fast?

Open
#226 1 comment 0 reactions 0 assignees View on GitHub
platform: browser
Dominant language
JavaScript
Stars
640
Forks
626
PR merge metrics
No merged PRs in 30d

Description

# 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

- [X] I searched for existing GitHub issues
- [ ] I updated all Cordova tooling to most recent version
- [ ] I included all the necessary information above

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the browser case in Chrome with cordova-plugin-splashscreen 5.0.3, focusing on the show-function and the document.body timing. Trace the splash append and removal paths, then verify that the splashscreen appears without a null-body exception and is removed safely afterward.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.