Closed Bug 1179519 Opened 7 years ago Closed 5 years ago

Widget fails to open new tab if Firefox is killed in the background by the OS

Categories

(Firefox for Android Graveyard :: Search Activity, defect, P5)

defect

Tracking

(firefox38.0.5 affected, firefox39 affected, firefox40 affected, firefox41 affected, firefox42 affected, fennec+)

RESOLVED DUPLICATE of bug 1366993
Tracking Status
firefox38.0.5 --- affected
firefox39 --- affected
firefox40 --- affected
firefox41 --- affected
firefox42 --- affected
fennec + ---

People

(Reporter: kbrosnan, Unassigned)

References

Details

* To get consistent behavior enable "Don't keep activities" in the developer options. Else you need to create a memory pressure event to get the os to kill Firefox

* Launch Firefox for Android
* Browse to a website, may I suggest https://www.mozilla.org
* Add the search widget to the homescreen
* tap the search widget "new tab button"

Results
  No new tab opened, Firefox is focused with the site loaded in the setup
Expected
  New tab created
Assignee: nobody → margaret.leibovic
tracking-fennec: ? → +
See Also: → 1184514
Looks like mfinkle ran into something like this when testing the original patch :(
https://bugzilla.mozilla.org/show_bug.cgi?id=1035642#c12

wesj, do you remember looking into this at all?
Flags: needinfo?(wjohnston)
So, the SearchWidget tries to open a new tab by launching an empty ACTION_VIEW intent:
http://mxr.mozilla.org/mozilla-central/source/mobile/android/search/java/org/mozilla/search/SearchWidget.java#77

On quick glance, it looks like our logic in `onNewIntent` always opens a new tab, regardless of checking the URL:
http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/GeckoApp.java#1866

However, if the activity has been killed, we'll go through `onCreate` instead, and in `initialize`, we'll check to see if there is a URI before opening a new tab:
http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/GeckoApp.java#1476

I wonder if instead of checking isExternalUrl before opening a new tab, we should be checking if the intent is ACTION_VIEW. But I want to spend some more time understanding this logic before making any logic changes like that.

mhaigh, did you get familiar with all this while working on tab queues? What do you think we should do?
Flags: needinfo?(mhaigh)
This code is quite difficult to follow.  

There are four places where we do incoming Intent handling: BrowserApp onCreate & onNewIntent and GeckoApp onNewIntent & initialize and we seem to be duplicating code between the two GeckoApp methods (we handle ACTION_LAUNCH_SETTINGS the exact same way in these two methods, as we do with ACTION_ALERT_CALLBACK and HELPER_BROADCAST_ACTION).  I don't fully understand the logic behind initialize and onNewIntent but I'd say that it could do with some cleanup and documentation.

But you're right in that in initialize, if the isExternalURL flag is false then we never handle the intent (but we will set the browser toolbar title - http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/BrowserApp.java#771)

It'd be good if we could review the code in GeckoApp onNewIntent & initialize and try to bring them more in line with each other.
Flags: needinfo?(mhaigh)
Yay, Yep! Do it (someone else do it I mean)!
Flags: needinfo?(wjohnston)
Duplicate of this bug: 1218663
Assignee: margaret.leibovic → nobody
Priority: -- → P5
Duplicate of this bug: 1339919
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1366993
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.