Closed Bug 947606 Opened 11 years ago Closed 7 years ago

Tabs opened from other apps can disappear on OOM

Categories

(Firefox for Android Graveyard :: General, defect, P5)

25 Branch
All
Android
defect

Tracking

(fennec+)

RESOLVED WORKSFORME
Tracking Status
fennec + ---

People

(Reporter: allo, Unassigned, Mentored)

References

Details

(Whiteboard: [lang=java])

User Agent: Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20100101 Firefox/6.0 (Beta/Release)

Steps to reproduce:

- use another app, i.e. twitter to open links in firefox
- switch after each link back to the other app, to let the page load in background
- have a slow internet connection
- open a few links without much time between them
- (maybe relevant: links are having redirections i.e. t.co before the page starts loading)


Actual results:

- when the other tab still did not load anything from the page (or at least did not set a title to the tab), the new link replaces the old tab


Expected results:

- a new tab is openend, both tabs keep loading their page
Version: unspecified → Firefox 25
I believe I've seen this before (I alluded to it in bug 947605). I'm guessing the newly opened tab is not saved because Gecko has not started yet so when the browser starts again, the tab is missing.

Can you try the following, and see if your newly opened tab appears?
  1) Opening a link from a separate app
  2) Returning to the app before the page loads
  3) Returning to the home screen
  4) Opening Firefox directly

If it's like what I've seen, a workaround would be to wait a little while for the page to actually start loading before switching back to the other app.

> - switch after each link back to the other app, to let the page load in background

Side note: Unfortunately, due to restrictions on the Android Activity lifecycle, we do not load a tab in the background while the user is in another app.
OS: Linux → Android
Hardware: x86_64 → All
At least switching to another app and back continues loading the active tab, as long as the network is not interrupted. If i stay in firefox until the title of the page is loaded, the url seems to stay assigned to the tab.

I guess the current url should be stored when a page starts loading, so its not lost when android stops the activity.
Is this still an issue? Any way to progress this bug and track this? This sounds extremely bad.
Flags: needinfo?(michael.l.comella)
It still seems related to https://bugzilla.mozilla.org/show_bug.cgi?id=947605

I guess the problem here is that new tabs can replace blank tabs?
This would mean together with the other bug, that a slow loading page may be treated as blank.

Not sure how to debug it properly, i guess first there should be some debugging in #947605 about how (background) tabs are stored and how they are reloaded when the activity gets created after it was swapped out by android.
When the tabs somehow store their current url, even when it did not finish loading, then it should be easy to avoid replacing another tab.
I can reproduce a simpler version of this issue pretty consistently with the following steps on FF 29, Galaxy Nexus:
1) Open Twitter
2) Select a link and open in Firefox
3) (As quickly as possible) Hit the recent apps button and select Twitter
4) Open the recent apps tray and swipe to close Firefox
5) Go to the home screen
6) Open Firefox

Expected: The opened tab is loading
Actual: The homescreen is loaded and the new tab is not present

I suspect the problem is that any tab that is not loaded in Gecko is lost when Firefox gets OOMed.

I imagine this is a bigger problem on slower devices with less memory as Gecko takes a longer time to load (i.e. the page will not get stored as a previously opened tab in Gecko) and with less RAM (i.e. Firefox is cleared from background memory more frequently).

However, I cannot reproduce this during normal use (at least after testing for ten minutes and my regular usage) so I'm wondering how critical this is to fix. Alexander, do you still see this regularly?
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(michael.l.comella) → needinfo?(alexander_schier)
Summary: opening a second tab sometimes replaces the newest loading tab → Tabs opened from other apps can disappear on OOM
(In reply to Alexander Schier from comment #0)
> - use another app, i.e. twitter to open links in firefox
> - switch after each link back to the other app, to let the page load in
> background

How do you switch back to the other app?  If you use the "back" button, then the tab will disappear; this is intentional and is consistent with how other Android apps behave, though I see how it can be unexpected.  (It's similar to what happens if you click a link on a web page and then press "back" to get back to the original page -- the link you clicked is no longer open.)

To switch back to the previous app without stopping the loading of the link, you can use the "home" or "recent apps" buttons instead of the "back" button.
(In reply to Michael Comella (:mcomella) from comment #5)
> 4) Open the recent apps tray and swipe to close Firefox

Just to clarify, do you have Customize > Tabs > Always restore selected in the settings? If not (the default), no tabs should ever be restored after closing FF from the recent apps list.
> Just to clarify, do you have Customize > Tabs > Always restore selected in the settings?

Yes, I do. Sorry, I thought that had been changed to the default.
(In reply to Michael Comella (:mcomella) from comment #5)
> However, I cannot reproduce this during normal use (at least after testing
> for ten minutes and my regular usage) so I'm wondering how critical this is
> to fix. Alexander, do you still see this regularly?

Yes, at least on the Galaxy Nexus this is still an issue, especially while firefox and other apps get bigger while the device is somewhat limited. I guess there are even worse devices still in use.

(In reply to Matt Brubeck (:mbrubeck) from comment #6)
> How do you switch back to the other app?  If you use the "back" button, then
> the tab will disappear; this is intentional and is consistent with how other
> Android apps behave, though I see how it can be unexpected.
Thats clear. I use the application switcher to switch back and forth, to get most out of the connection by letting apps load in background.

I learned firefox will not continue loading in background (maybe it should employ a service, if this helps?), but twitter, mail apps and so on synchronize when another app is open.
Slow internet is a pest ;)
Flags: needinfo?(alexander_schier)
Now i had even disappearing Tabs in the Background.
Firefox 26.0.1, Nexus 7 with Android 4.2

I had three open tabs, and reading the foreground tab. When i opened the tab area, i saw two thumbnails of fully loaded pages. When i tapped the first one, the home-tab opened, the thumbnail changed. then i tapped the second one with the same effect.
tracking-fennec: --- → ?
tracking-fennec: ? → +
is this a regression?
It would be helpful to know whether this is a regression or not.
I can only reproduce the bug with the STR form the comment 5.
Following the steps form the comment 5 I can reproduce the bug even on Google Chrome.
Tested on Google Nexus 7 (Android 4.4.2).
I agree with Michael in comment 5 that this is likely due to Gecko not being loaded.

All session saving happens on the Gecko side. When a URL is launched from some external app, we create a tab stub, shown immediately, while waiting for Gecko to load. If Fennec is killed before Gecko is ready, the URL won't be saved. The only way around this would be to add additional session restore logic in the Activity itself.

I don't think we'll be fixing this bug anytime soon, especially since other browsers have the same issue as Flaviu just mentioned. That said, bug 965137 should at least improve session restore a bit.
(In reply to Brian Nicholson (:bnicholson) from comment #14)
> I don't think we'll be fixing this bug anytime soon,

Then might this be worth a SUMO comment? needinfo to Roland.

Roland, see comment 5 for the (imo) most descriptive comment and STR.
Flags: needinfo?(rtanglao)
hi :mcomella if this happens in many apps and not just twitter than we might want to document it, if it's just twitter and it's hard to reproduce as it seems in comment 5 then we won't document it.

I will test this on a few devices and get :michaelverdi and :joni to look at it too and we'll decide if we need to document this in ff29 and let you know.
Flags: needinfo?(rtanglao)
It should occur in any apps, though I would say it's fairly hard to reproduce, at least on my Galaxy Nexus. However, this may not be the case on lower end devices - I recommend testing on those especially.
Whiteboard: [mentor=mcomella][lang=java]
Assignee: nobody → vivekb.balakrishnan
spoke with mcomella on irc. I would like to investigate this bug and I've reassigned it to myself.
changed bug status
Status: NEW → ASSIGNED
Mentor: michael.l.comella
Whiteboard: [mentor=mcomella][lang=java] → [lang=java]
Unassigning this bug due to inactivity. Feel free to take it back if you plan on working on it, Vivek.
Assignee: vivekb.balakrishnan → nobody
Status: ASSIGNED → NEW
filter on [mass-p5]
Priority: -- → P5
By the way: Did you do something related to this bug? It seems to be way better with recent firefox mobile versions.
(In reply to Alexander Schier from comment #22)
> By the way: Did you do something related to this bug? It seems to be way
> better with recent firefox mobile versions.

I don't believe there was any effort to directly fix this bug but, given what we know (comment 14), perhaps other work has decreased Gecko startup time or RAM usage (so we don't have to restart gecko) and made us hang on to new tabs more easily.

Glad to hear it's working better though. :P
Mentor: bnicholson
Seems to be fixed since several versions.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → WORKSFORME
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.