apache / apache/cordova-android

Flash of the app's background color when resuming from the background

Open
#1,282 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
3.8k
Forks
1.6k
Avg merge
16h 18m
Merged PRs (30d)
11

Description

# Bug Report

## Problem
The app's background color regularly flashes over the contents of the app when I resume the app from the background

### What is expected to happen?
The app resumes without such a flash

### What does actually happen?
See the problem statement

## Information

https://user-images.githubusercontent.com/28525986/125789780-476eac7a-e616-40ac-af23-51fa78aa5574.mp4

In the video above, the white is the normal app content, and the green is the background color of the app (not the DOM, the Android view itself). You can see that as I return the app to the foreground from the app switcher, there's a brief period where the green color overrides the white. I used those 2 colors just to highlight the bug, but the problem is the same with the app's actual contents i.e. when I return to the app, the app's background (white in my case) flashes over the app's contents (i.e. the DOM). I'm not sure what's going on, it looks it's something happening with the webview itself. I am fairly certain it's not a style invalidation problem because style invalidations or repaints of the DOM don't show up when I profile the bug using dev tools. In fact in dev tools, the DOM is never repainted and there's no flash. Things I've tried:
- disabling the `onDeviceResume` and `onDevicePause` callbacks. When I say disable I mean that I put return; statements to make sure that those callbacks don't execute any logic. This didn't stop the problem
- using a transparent app background color. I thought this would allow the app's contents to show even when the background color is overlaying the contents, but instead it only made the flash dark (i.e. no background color for the app to show). This suggests that something is actually removing and restoring the Android view, but I don't know how to check for this
- removing all the contents of the DOM (i.e. setting `display: none;` to all visible content, and also to the `` and `` elements in another test). This essentially hides everything on screen, leaving only the app's background. In my video, that would mean only the green would be showing. The flash doesn't happen when I do this, perhaps unsurprisingly
- removing some of the heavier plugins I use, particularly [this background geolocation plugin](https://github.com/transistorsoft/cordova-background-geolocation-lt/) and the [the google maps plugin](https://github.com/mapsplugin/cordova-plugin-googlemaps/), but the problem doesn't go away
- using the basic cordova sample app to try to reproduce the problem but I haven't succeeded yet, the bug hasn't occurred

### Command or Code

N/A, please see the description above

### Environment, Platform, Device

- cordova android: versions 9 and 10
- device: Tecno Pop2 Plus

### Version information

- cordova CLI: 10
- plugins:
- branch-cordova-sdk 3.2.0 "branch-cordova-sdk"
- cordova-android-support-gradle-release 3.0.1 "cordova-android-support-gradle-release"
- cordova-plugin-android-notch 1.0.0 "AndroidNotch"
- cordova-plugin-android-permissions 1.0.2 "Permissions"
- cordova-plugin-camera 4.1.0 "Camera"
- cordova-plugin-compat 1.2.0 "Compat"
- cordova-plugin-contacts 3.0.1 "Contacts"
- cordova-plugin-device 2.0.3 "Device"
- cordova-plugin-enable-multidex 0.2.0 "Enable Multidex"
- cordova-plugin-file-transfer 1.7.1 "File Transfer"
- cordova-plugin-file 6.0.2 "File"
- cordova-plugin-googleplus 5.3.2 "Google SignIn"
- cordova-plugin-inappbrowser 3.2.0 "InAppBrowser"
- cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard"
- cordova-plugin-ionic-webview 2.5.1 "cordova-plugin-ionic-webview"
- cordova-plugin-ios-camera-permissions 1.2.0 "iOS Permissions"
- cordova-plugin-media-capture 3.0.3 "Capture"
- cordova-plugin-network-information 2.0.2 "Network Information"
- cordova-plugin-purchase 9.0.0 "Purchase"
- cordova-plugin-splashscreen 5.0.3 "Splashscreen"
- cordova-plugin-video-editor 1.1.3 "VideoEditor"
- cordova-plugin-whitelist 1.3.4 "Whitelist"
- cordova-plugin-x-socialsharing 5.6.3 "SocialSharing"
- cordova-sqlite-storage 5.0.0 "Cordova sqlite storage plugin - cordova-sqlite-storage plugin version"
- cordova.plugins.diagnostic 5.0.1 "Diagnostic"
- es6-promise-plugin 4.2.2 "Promise"
- pushwoosh-cordova-plugin 7.18.7 "Pushwoosh"

## Checklist

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

Contributor guide

Open the contributing guide

Research direction

The payload names no source file, test, or entry point. Start by reproducing the resume-from-background behavior on the Tecno Pop2 Plus with cordova-android 9 or 10 and inspect the Android WebView lifecycle; done means the app returns to the foreground without a background-color flash.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java, javascript
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.