apache / apache/cordova-plugin-inappbrowser

Issue when app has an active foreground service

Open
#845 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Java
Stars
1.1k
Forks
2.2k
PR merge metrics
No merged PRs in 30d

Description

# Bug Report

## Problem
If the app has an active foreground service, when the user closes the app in android task switcher, after having opened the inappbrowser once, the whole app is force closed which stops the active foreground service.
### What is expected to happen?
The active foreground service should not be stopped when closing the app window.

### What does actually happen?
The active foreground service is stopped when closing the app window. The issue only happens after the inappbrowser was opened, doesn't matter if it was closed after. It always stops the foreground service. Does not happen if the inappbrowser is never opened.

## Information
I solved the issue by destroying the webview (inAppWebView.destroy()) in closeDialog method. I don't understand why this is not the default behavior? Closing the dialog just replaces the webview contents with an "about:blank" page and keeps it in memory. If there is a reason for the webview not being destroyed, there should be at least a way to destroy it on dialog close to avoid this issue.

### Environment, Platform, Device
Android 10, Android Emulator

### Version information
Cordova 10.0.0, Cordova Android 9.0.0, Windows 10 2004, Android Studio 4.1.1, up-to-date Android SDK

## 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

Start with the in-app browser dialog's closeDialog path and the inAppWebView.destroy() workaround described in the report; reproduce the behavior on Android using an active foreground service. Done means closing the app window after opening and closing the in-app browser no longer force-closes the app or stops the foreground service.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.