Closed Bug 1408575 Opened 3 years ago Closed 7 months ago

Restoring a session id sometimes restores random tab or window

Categories

(WebExtensions :: General, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1538119

People

(Reporter: Manuel.Spam, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

I'm developer of a simple "Restore Tab" Addon:

https://addons.mozilla.org/en-US/firefox/addon/undoclosetabbutton/

Some days ago, I got the following bug report:

https://github.com/M-Reimer/undoclosetab/issues/19

This report is basically about a problem, that my Addon sometimes restores random tabs or even windows.

The only reason for this, I can think of, is, that in some situation the session IDs not really match the actual tabs and windows. Something seems to be "mixed up" sometimes. Maybe there can be some case where the IDs are regenerated for some reason? And if this happens, Addons don't receive the "sessions.onChanged" event?

Problem is, that this can't be reproduced easily. I also got this issue in the past, but haven't seen it since then.
Priority: -- → P3
Product: Toolkit → WebExtensions
Blocks: 1476144
No longer blocks: Session_managers

I can reproduce it pretty consistently with my current session.

Every time the wrong tab gets restored, I get a bunch of
Unchecked lastError value: Error: ID already exists: [ID?]
errors from resource://gre/modules/ExtensionCommon.jsm:746
[ID?] is different for every error, and can be BA:48 or BA:6 or even MoreClosedTabs
Each of them have the same details:
withLastError resource://gre/modules/ExtensionCommon.jsm:746
create chrome://browser/content/child/ext-menus.js:148
I also get an uncaught exception: Object error in the end.

When the correct tab is restored, I only get the uncaught exception: Object error.

When I close a tab, I get this error (repeated 3 times as meant by the 3):

[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMWindowUtils.removeSheetUsingURIString]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: resource://gre/modules/ExtensionCommon.jsm :: runSafeSyncWithoutClone :: line 75" data: no] 3 ExtensionCommon.jsm:75:12
Details:
runSafeSyncWithoutClone resource://gre/modules/ExtensionCommon.jsm:75
cleanup resource://gre/modules/ExtensionContent.jsm:402
close resource://gre/modules/ExtensionContent.jsm:925
destroyed resource://gre/modules/ExtensionContent.jsm:1010
observe resource://gre/modules/ExtensionContent.jsm:1028

(In reply to Thomas Bertels from comment #1)

Every time the wrong tab gets restored, I get a bunch of
Unchecked lastError value: Error: ID already exists: [ID?]
errors from resource://gre/modules/ExtensionCommon.jsm:746

These IDs are created by my Add-on. They should not duplicate as they contain the session ID and per definition the session ID should be unique in this session.

After some searching, I've found this bug report:
https://bugzilla.mozilla.org/show_bug.cgi?id=1538119

In my opinion the problem behind this "random tab restore" is discussed more in detail there. Including a working testcase, a screencast and a suggestion on where this could be fixed in the Firefox source code.

So now we know why this happens and why it does not happen all the time and for everyone. Actually it is really easy to reproduce.

  • Open a new Firefox session (be sure it is really new by unchecking "restore last session" in the Firefox settings and restarting Firefox once).
  • Install my Add-on and open two random tabs.
  • Close both tabs, right click on the toolbar icon created by my Add-on. There will be two entries for closed tabs.
  • Now go to the Firefox preferences and check "restore last session"
  • Close Firefox, reopen it
  • Have a look at the context menu of my Add-on again. There should still be two entries.
  • Now create two random tabs again and close them.
  • Have a look at the context menu of my Add-on again. Still two entries when there should be four now and from this point on it may be possible that you don't restore the tab you think you would as the session IDs are duplicated now.

As the other bug report has better information, I'll mark this one as duplicate.

Status: NEW → RESOLVED
Closed: 7 months ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1538119
You need to log in before you can comment on or make changes to this bug.