Fluent localization can fail to happen at all, if a document flushes layout before parsing finishes
Categories
(Core :: Internationalization, enhancement, P3)
Tracking
()
People
(Reporter: bzbarsky, Assigned: zbraniecki)
References
Details
Attachments
(1 file)
When debugging the intermittent failure from bug 1525935 landing, I discovered that what happens is the following:
- We call Document::LocalizationLinkAdded for about:plugins, with "toolkit/about/aboutPlugins.ftl" as the link href.
- We add the href to mL10nResources and block the load event.
- We call Document::OnL10nResourceContainerParsed and do the various InitializeLocalization() bits.
- We later call into nsHtml5TreeOpExecutor::DidBuildModel. mLayoutStarted is true, so we never call TriggerInitialDocumentTranslation() and hence never end up in InitialDocumentTranslationCompleted() and hence never unblock the load event.
Obviously in this case the document never gets localized (either before my patch or after it).
OK, why is mLayoutStarted true? Because about:plugins has a subframe it loads from <chrome://global/content/directionDetector.html>. And when that subframe is ready to fire its load event, it flushes layout (because you need to do that before firing load, because of web fonts). And flushing layout on the subframe needs to flush layout on the parent. And a forced flush like this will start layout if it hasn't started yet. If the subframe finishes loading before the parent document finishes parsing, we end up with a failure here.
Seems to me that we should be doing TriggerInitialDocumentTranslation() even if mLayoutStarted is true. That's what we do for XML (including XHTML), but not what we do for HTML or XUL, for some reason...
Are there other reasons localization could fail? For example, what happens if in DocumentL10n::TriggerInitialDocumentTranslation "elem" ends up null? Will that prevent the promise from settling? What about if "promise" ends up null? Should we just sync-call InitialDocumentTranslationCompleted() in that case?
| Assignee | ||
Comment 1•7 years ago
|
||
Seems to me that we should be doing TriggerInitialDocumentTranslation() even if mLayoutStarted is true. That's what we do for XML (including XHTML), but not what we do for HTML or XUL, for some reason...
Hmmm, That means that we can't actually block layout on localization, because subframe can bypass that block anyway? I'm not sure if I understand. Can we fix that by blocking the layout anyway until l10n is completed or do we have to allow for layout to start even if l10n is not done?
Are there other reasons localization could fail? For example, what happens if in DocumentL10n::TriggerInitialDocumentTranslation "elem" ends up null? Will that prevent the promise from settling? What about if "promise" ends up null?
There shouldn't be a scenario like that, so if you see one, we should fix it by always returning.
| Reporter | ||
Comment 2•7 years ago
|
||
That means that we can't actually block layout on localization
You can't realiably block layout on anything. If the page has script and the script asks for layout info, we will do layout.
What you can do is have us not do our default (unforced) layout-starting until localization is done. That's what we do right now.
do we have to allow for layout to start even if l10n is not done
Right now you have to allow that; see above.
There shouldn't be a scenario like that
Why are we null-checking "promise", then?
| Assignee | ||
Comment 3•7 years ago
|
||
Right now you have to allow that; see above.
Makes sense.
Why are we null-checking "promise", then?
Where?
Seems to me that we should be doing TriggerInitialDocumentTranslation() even if mLayoutStarted is true.
That sounds reasonable then.
| Reporter | ||
Comment 4•7 years ago
|
||
Where?
That sounds reasonable then.
OK, do we have someone planning to work on that?
| Assignee | ||
Comment 5•7 years ago
|
||
OK, do we have someone planning to work on that?
It'll be me. I'll try to get to it within a week or two.
Comment 6•7 years ago
|
||
Zibi, will the patch be safe for beta uplift? That would decide whether or not the patch for bug 1525935 gets uplifted or not as that’s blocked by this.
| Reporter | ||
Comment 7•7 years ago
|
||
It's not clear to me that the patch for bug 1525935 itself is safe for beta uplift, especially at this late date.
| Assignee | ||
Comment 8•7 years ago
|
||
| Assignee | ||
Updated•7 years ago
|
Comment 10•7 years ago
|
||
Comment 11•7 years ago
|
||
| bugherder | ||
Updated•7 years ago
|
Description
•