Closed Bug 1741804 Opened 6 months ago Closed 6 months ago

Autocompleting/Displaying localStorage with lots of entries freezes Firefox

Categories

(DevTools :: Console, defect, P3)

Firefox 94
defect

Tracking

(firefox96 verified)

VERIFIED FIXED
96 Branch
Tracking Status
firefox96 --- verified

People

(Reporter: alexanderhausmann, Assigned: nchevobbe)

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0

Steps to reproduce:

  • store a lot of UTF16 characters in localStorage (~ 3,000,000)
  • enter "localStorage" in the Dev Console

Actual results:

Whole firefox freezes (mostly CPU usage, some additional RAM usage) for at least 10 seconds (Ryzen 5900x).

This is especially bad since the autocomplete will try to complete e.g. "localS" to "localStorage" which triggers the freeze

I understand if this cannot be fixed, but at least give me an option to turn off the "return preview" of the console, since the calculation of that preview seems to be the reason for the freeze.

Expected results:

only freeze the tab related to this dev console

Summary: Dev Console autocomplete triggers Firefox Freeze → Dev console autocomplete triggers Firefox freeze

The Bugbug bot thinks this bug should belong to the 'DevTools::Console' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → Console
Product: Firefox → DevTools

Nicolas: can you share the setting to disable instant evaluation and try to reproduce the issue.

Flags: needinfo?(nchevobbe)

Instant evaluation can be disabled from the console settings menu (see screenshot)

I think the issue is caused by https://searchfox.org/mozilla-central/rev/bc5e79f3ae0f42cb4a6ebd05fc32f48a3829059d/devtools/server/actors/object/utils.js#336-343 , where we do loop through all the entries, even if in the end we're only showing a preview of 10 entries in the console :/

Flags: needinfo?(nchevobbe)
Assignee: nobody → nchevobbe
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Summary: Dev console autocomplete triggers Firefox freeze → Autocompleting/Displaying localStorage with lots of entries freezes Firefox

The function, which is only used from previewers.js to retrieve
the first then interesting properties of an object, has a special
case for (local|session)Storage so we loop through their entries
and not their properties.
We're using storage#key to achieve this, but the problem is that
the function is quite slow, and if the storage object has a lot
of entries, it can end up freezing Firefox.
In order to avoid such freeze, for storage object, we're not returning
an array but an iterable object, which most of the time will only be
called 10 times and prevent any perf issue.

Pushed by nchevobbe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/1e7a99bf6c17
[devtools] Fix getPropNamesFromObject + storage performance issues. r=jdescottes.
Severity: -- → S3
Priority: -- → P3
Status: ASSIGNED → RESOLVED
Closed: 6 months ago
Resolution: --- → FIXED
Target Milestone: --- → 96 Branch
Flags: qe-verify+

Reproduced the bug using an affected Firefox 94.0, on Win 10 x64.

The issue is verified as fixed on 96.0-build2, under Win 10 x64. Thanks, Nicolas, for your help in reproducing this bug.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.