Closed Bug 1761464 Opened 3 years ago Closed 3 years ago

Browser freezes after enabling/disabling languages for spell checking

Categories

(Core :: Spelling checker, defect)

Firefox 100
Desktop
All
defect

Tracking

()

VERIFIED FIXED
100 Branch
Tracking Status
firefox98 --- disabled
firefox99 --- disabled
firefox100 + verified

People

(Reporter: hyacoub, Assigned: dminor)

References

(Blocks 1 open bug)

Details

Attachments

(5 files, 1 obsolete file)

Attached file aboutsupport.txt

Affected versions

Firefox 100.0a1

Affected platforms

Windows 10 x64: Please check aboutsupport attached
macOS 11.6:
MacBook Pro (13-inch, 2019, Four Thunderbolt 3 ports)
Processor 2,4 GHz Quad-Core Intel Core i5
Memory 16 GB 2133 MHz LPDDR3

Steps to reproduce

  1. Open Firefox.
  2. Go to bugzilla.mozilla.org or any other websites.
  3. Right click on the search field to open the context menu.
  4. From the context menu make sure check spelling is enabled -> Languages.
  5. Enable/Disable any of the languages.
  6. Try right away to open the context menu or to switch to another tab.

Expected result

Browser shouldn't freeze after enabling/disabling languages for spell checking.

Actual Result

Browser freezes after enabling/disabling languages for spell checking.

Note

On the OS's mentioned in the affected platform the freeze lasted for 4-5 seconds.
On a Dell G5 laptop with processor Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz and 16GB RAM the freeze laster for 1 second.

Attached video 2022-03-25_11h40_34.mp4
Assignee: nobody → dminor

This reproduces for me, but only with 5 or 6 dictionaries installed. It was fine, even on older machines, with two dictionaries. Changing the UI code to not wait on changing dictionaries makes things better on my machine. I'm going to check that we're not reloading all of the dictionaries when adding a single dictionary, or something similar, before changing the UI code because I'm surprised that the number of dictionaries installed would make a difference in this case.

It seems like there was always jank while loading a dictionary, but now that we're potentially loading 5 or 6 dictionaries at once, the jank lasts 5 or 6 times as long. It would be nice to move loading the dictionaries to a background thread, but we may be stuck keeping this on the main thread. In that case, we could try chaining promises together, so the main thread is not blocked for the full time it takes to load the dictionaries.

So it looks like we can only use RLBoxHunspell from the main thread [1], so the best we can do here is to try to break up the dictionary loading so it doesn't block the main thread for several seconds in a row.

[1] https://searchfox.org/mozilla-central/rev/1ca8ea11406642df4a2c6f81f21d683817af568d/extensions/spellcheck/hunspell/glue/RLBoxHunspell.cpp#43

QA has checked that the issue doesn't reproduce with the changes in this try job: https://treeherder.mozilla.org/jobs?repo=try&revision=685f80ae05ac05da508b84c140d43622c378e0a1. I'll be pushing it for review shortly.

This returns a promise from selectDictionaries rather than using async/await
to synchronize sending events.

This adds an mEnabled flag which is used to hide dictionaries from the
spellchecker rather than freeing them. Loading dictionaries is an expensive
process which must occur on the main thread. By retaining dictionaries in
memory, we avoid having to reload them. If the number of dictionaries in use
exceeds a set number (10), we'll attempt to free any disabled dictionaries to
avoid memory use growing indefinitely.

Depends on D142556

Loading dictionaries is time consuming and must occur on the main thread. By
loading them lazily, we can hopefully spread these loads across multiple calls
rather than loading them all at once, which results in noticeable jank on
slower systems.

Depends on D142557

Status: NEW → ASSIGNED
Attachment #9270234 - Attachment is obsolete: true
Attachment #9270234 - Attachment is obsolete: false

Comment on attachment 9270234 [details]
Bug 1761464 - Return promise from InlineSpellChecker.selectDictionaries; r=gijs!

Revision D142556 was moved to bug 1762629. Setting attachment 9270234 [details] to obsolete.

Attachment #9270234 - Attachment is obsolete: true
Pushed by dminor@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/262849952d57 Don't free dictionaries when they are no longer in use; r=smaug https://hg.mozilla.org/integration/autoland/rev/34396045f417 Pass nsCString to RLBoxHunspell::Create; r=smaug https://hg.mozilla.org/integration/autoland/rev/0a103b6714e3 Load dictionaries lazily; r=smaug

Verified as fixed on Firefox 100.0a1 (2022-04-04) on Windows 10 x64, Ubuntu 20.04 x64 and on macOS 11.6.

Status: RESOLVED → VERIFIED
No longer blocks: 1402822
Depends on: 1402822
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: