apache / apache/cordova-plugin-inappbrowser

Fatal error if InAppBrowser is close immediately

Open
#368 5 comments 3 reactions 0 assignees View on GitHub
platform: android support
Dominant language
Java
Stars
1.1k
Forks
2.2k
PR merge metrics
No merged PRs in 30d

Description

I have this error when the inAppBrowser is close soon enough ( for eg within 1 sec )

> `java.lang.NullPointerException: Attempt to invoke virtual method 'void org.apache.cordova.inappbrowser.InAppBrowserDialog.show()' on a null object reference`

I could solve the problem by adding a null check on line no. 282 on inAppBrowser.java as follows
replace `dialog.show();` with `if(dialog != null) dialog.show();`

[screenshot](http://prntscr.com/lti6lm)

I am not an expert on java android and so can someone confirm this fix or give a good way to fix the problem.

Thx

Contributor guide

Open the contributing guide

Research direction

Start in inAppBrowser.java around line 282 and reproduce the reported case by closing the InAppBrowser within about one second. Trace whether dialog can be null at that point and verify that the chosen fix prevents the NullPointerException without breaking normal dialog display.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.