Closed Bug 1612824 Opened 4 years ago Closed 4 years ago

Search Services shouldn't use reInit for when the locale is dynamically changed.

Categories

(Firefox :: Search, task, P3)

task
Points:
5

Tracking

()

RESOLVED FIXED
82 Branch
Iteration:
82.1 - Aug 24 - Sep 6
Tracking Status
firefox82 --- fixed

People

(Reporter: standard8, Assigned: standard8)

References

Details

Attachments

(1 file)

_reInit was only really designed for use in tests. However, we are currently using it for when locales are dynamically changed.

The good thing is, that dynamically changing locale also currently forces a restart of the browser.

At some stage, once Fluent is mature enough, that is likely to change and there will be no restart.

The bad thing with _reInit is that we don't send out notifications of any changes.

At the moment, the worst case I've found is that if the default browser should be changed as a result of the switch, then we will not pick that change up until a subsequent restart - potentially confusing the user. This is because reInit doesn't send out any notifications.

Ideally, we should be using something like a simplified maybeReloadEngines (i.e. after bug 1610293), and ensure that the notifications get sent out.

Right now, we restart on locale change through prefs as a "better be safe than sorry". It's not that restarts are really required for most of our code, it's just niches.

I think the bigger problem here is that we have more and more code paths that do stuff in response to locale changes, and no signal on the Firefox-level that indicates "we're done switching locales, go on with life".

In the browser, that might be OK, but I wouldn't be surprised if this could lead to intermittent test failures at some point down the road.

Do we have anything that allows us to trigger async tasks across all kinds of places and processes, and wait for all of that to finish?

(In reply to Axel Hecht [:Pike] from comment #2)

Right now, we restart on locale change through prefs as a "better be safe than sorry". It's not that restarts are really required for most of our code, it's just niches.

I thought it was because full language switching wasn't in place yet.

Do we have anything that allows us to trigger async tasks across all kinds of places and processes, and wait for all of that to finish?

Not as far as I know.

What the search service is doing here is bad though - it is doing more work than necessary, and not actually doing all of the work it should be doing.

(In reply to Mark Banner (:standard8) from comment #0)

_reInit was only really designed for use in tests. However, we are currently using it for when locales are dynamically changed.

My recollection is that it happened the other way around: the search service reInit code was introduced for locale switching in Fennec, and then I abused it for tests to test absearch stuff using normal xpcshell tests instead of needing marionette tests.

Severity: normal → N/A
Type: defect → task
Points: --- → 5
Iteration: --- → 82.1 - Aug 24 - Sep 6
Assignee: nobody → standard8

reInit is unsafe as it completely removes the existing data before reloading. If something interrupts the process that can cause dataloss.

_maybeReloadEngines is safer as it does changes progressively, it also now handles removing engines, which it didn't before.

Depends on D88023

Pushed by mbanner@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/abf8d8b24845
Search Services shouldn't use reInit for when the locale is changed or the ignore list is updated. r=daleharvey
Pushed by mbanner@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/b384152d8539
Search Services shouldn't use reInit for when the locale is changed or the ignore list is updated. r=daleharvey
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 82 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: