mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Backed out 4 changesets (bug 1836974) mochitest failures in dom/workers/test/browser_privilegedmozilla_remoteworker.js CLOSED TREE
Backed out changeset 2da6acc9b08d (bug 1836974) Backed out changeset 9204d672ecd9 (bug 1836974) Backed out changeset 271e1c767696 (bug 1836974) Backed out changeset 349fa2acc5f8 (bug 1836974)
This commit is contained in:
parent
33274c1f7d
commit
4d8a23d28f
@ -75,7 +75,6 @@ const intermittently_loaded_scripts = {
|
||||
|
||||
// Translations code which may be preffed on.
|
||||
"resource://gre/actors/TranslationsChild.sys.mjs",
|
||||
"resource://gre/modules/translation/LanguageDetector.sys.mjs",
|
||||
"chrome://global/content/translations/language-id-engine.sys.mjs",
|
||||
"resource://gre/modules/ConsoleAPIStorage.sys.mjs", // Logging related.
|
||||
|
||||
|
@ -3679,13 +3679,6 @@ pref("browser.translations.simulateUnsupportedEngine", false);
|
||||
pref("browser.translations.chaos.errors", false);
|
||||
pref("browser.translations.chaos.timeoutMS", 0);
|
||||
|
||||
// A pref to manage the use of fastText for language detection in Translations.
|
||||
// The feature was initially built using fastText, but we are now putting it
|
||||
// behind a pref while we investigate some performance improvements.
|
||||
// In the meantime, we will use CLD2, which is already available in tree.
|
||||
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1836974
|
||||
pref("browser.translations.languageDetection.fastText", false);
|
||||
|
||||
// When a user cancels this number of authentication dialogs coming from
|
||||
// a single web page in a row, all following authentication dialogs will
|
||||
// be blocked (automatically canceled) for that page. The counter resets
|
||||
|
@ -7,20 +7,6 @@ import { clearTimeout, setTimeout } from "resource://gre/modules/Timer.sys.mjs";
|
||||
|
||||
const WORKER_URL = "resource://gre/modules/translation/cld-worker.js";
|
||||
|
||||
/**
|
||||
* The length of the substring to pull from the document's text for language
|
||||
* identification.
|
||||
*
|
||||
* This value should ideally be one that is large enough to yield a confident
|
||||
* identification result without being too large or expensive to extract.
|
||||
*
|
||||
* At this time, this value is not driven by statistical data or analysis.
|
||||
*
|
||||
* For the moment, while we investigate which language identification library
|
||||
* we would like to use, keep this logic in sync with language-id-engine.sys.mjs
|
||||
*/
|
||||
const DOC_TEXT_TO_IDENTIFY_LENGTH = 1024;
|
||||
|
||||
export var workerManager = {
|
||||
// Since Emscripten can handle heap growth, but not heap shrinkage, we
|
||||
// need to refresh the worker after we've processed a particularly large
|
||||
@ -164,27 +150,4 @@ export var LanguageDetector = {
|
||||
|
||||
return workerManager.detectLanguage(aParams);
|
||||
},
|
||||
|
||||
/**
|
||||
* Attempts to determine the language in which the document's content is written.
|
||||
*
|
||||
* For the moment, while we investigate which language identification library
|
||||
* we would like to use, keep this logic in sync with language-id-engine.sys.mjs
|
||||
* @returns {string | null}
|
||||
*/
|
||||
async detectLanguageFromDocument(aDocument) {
|
||||
// Grab a selection of text.
|
||||
let encoder = Cu.createDocumentEncoder("text/plain");
|
||||
encoder.init(aDocument, "text/plain", encoder.SkipInvisibleContent);
|
||||
let text = encoder
|
||||
.encodeToStringWithMaxLength(DOC_TEXT_TO_IDENTIFY_LENGTH)
|
||||
.replaceAll("\r", "")
|
||||
.replaceAll("\n", " ");
|
||||
|
||||
const { language, confident } = await workerManager.detectLanguage({
|
||||
text,
|
||||
});
|
||||
|
||||
return confident ? language : null;
|
||||
},
|
||||
};
|
||||
|
@ -13,17 +13,6 @@ XPCOMUtils.defineLazyGetter(lazy, "console", () => {
|
||||
});
|
||||
});
|
||||
|
||||
ChromeUtils.defineESModuleGetters(lazy, {
|
||||
LanguageDetector:
|
||||
"resource://gre/modules/translation/LanguageDetector.sys.mjs",
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
lazy,
|
||||
"useFastTextPref",
|
||||
"browser.translations.languageDetection.fastText"
|
||||
);
|
||||
|
||||
/**
|
||||
* @typedef {import("./TranslationsChild.sys.mjs").LanguageIdEngine} LanguageIdEngine
|
||||
* @typedef {import("./TranslationsChild.sys.mjs").TranslationsEngine} TranslationsEngine
|
||||
@ -217,7 +206,7 @@ export class AboutTranslationsChild extends JSWindowActorChild {
|
||||
}
|
||||
return this.#convertToContentPromise(
|
||||
this.#getTranslationsChild()
|
||||
.getOrCreateLanguageIdEngine()
|
||||
.createLanguageIdEngine()
|
||||
.then(engine => {
|
||||
this.languageIdEngine = engine;
|
||||
})
|
||||
@ -261,7 +250,6 @@ export class AboutTranslationsChild extends JSWindowActorChild {
|
||||
* @returns {Promise<{ langTag: string, confidence: number }>}
|
||||
*/
|
||||
AT_identifyLanguage(message) {
|
||||
if (lazy.useFastTextPref) {
|
||||
if (!this.languageIdEngine) {
|
||||
const { Promise, Error } = this.contentWindow;
|
||||
return Promise.reject(
|
||||
@ -275,17 +263,6 @@ export class AboutTranslationsChild extends JSWindowActorChild {
|
||||
.then(data => Cu.cloneInto(data, this.contentWindow))
|
||||
);
|
||||
}
|
||||
return this.#convertToContentPromise(
|
||||
lazy.LanguageDetector.detectLanguage(message).then(data =>
|
||||
Cu.cloneInto(
|
||||
// This language detector reports confidence as a boolean instead of
|
||||
// a percentage, so we need to map the confidence to 0.0 or 1.0.
|
||||
{ langTag: data.language, confidence: data.confident ? 1.0 : 0.0 },
|
||||
this.contentWindow
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string[]} messageBatch
|
||||
|
@ -8,8 +8,6 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
||||
"chrome://global/content/translations/translations-engine.sys.mjs",
|
||||
LanguageIdEngine:
|
||||
"chrome://global/content/translations/language-id-engine.sys.mjs",
|
||||
LanguageDetector:
|
||||
"resource://gre/modules/translation/LanguageDetector.sys.mjs",
|
||||
});
|
||||
|
||||
/**
|
||||
@ -83,16 +81,11 @@ export class TranslationsChild extends JSWindowActorChild {
|
||||
return this.document.documentElement.lang;
|
||||
case "Translations:IdentifyLanguage": {
|
||||
try {
|
||||
if (data.useFastText) {
|
||||
const engine = await this.createLanguageIdEngine();
|
||||
if (!engine) {
|
||||
return null;
|
||||
}
|
||||
return engine.identifyLanguageFromDocument(this.document);
|
||||
}
|
||||
return lazy.LanguageDetector.detectLanguageFromDocument(
|
||||
this.document
|
||||
);
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
@ -151,7 +144,7 @@ export class TranslationsChild extends JSWindowActorChild {
|
||||
});
|
||||
}
|
||||
|
||||
getOrCreateLanguageIdEngine() {
|
||||
createLanguageIdEngine() {
|
||||
return lazy.LanguageIdEngine.getOrCreate(() => {
|
||||
if (this.#isPageHidden) {
|
||||
throw new Error("The page was already hidden.");
|
||||
|
@ -99,12 +99,6 @@ XPCOMUtils.defineLazyPreferenceGetter(
|
||||
"browser.translations.simulateUnsupportedEngine"
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
lazy,
|
||||
"useFastTextPref",
|
||||
"browser.translations.languageDetection.fastText"
|
||||
);
|
||||
|
||||
// At this time the signatures of the files are not being checked when they are being
|
||||
// loaded from disk. This signature check involves hitting the network, and translations
|
||||
// are explicitly an offline-capable feature. See Bug 1827265 for re-enabling this
|
||||
@ -1677,9 +1671,7 @@ export class TranslationsParent extends JSWindowActorParent {
|
||||
}
|
||||
|
||||
async queryIdentifyLanguage() {
|
||||
return this.sendQuery("Translations:IdentifyLanguage", {
|
||||
useFastText: lazy.useFastTextPref,
|
||||
}).catch(error => {
|
||||
return this.sendQuery("Translations:IdentifyLanguage").catch(error => {
|
||||
if (this.#isDestroyed) {
|
||||
// The actor was destroyed while this message was still being resolved.
|
||||
return null;
|
||||
|
@ -44,9 +44,6 @@ const DOC_LANGUAGE_DETECTION_THRESHOLD = 0.65;
|
||||
* identification result without being too large or expensive to extract.
|
||||
*
|
||||
* At this time, this value is not driven by statistical data or analysis.
|
||||
*
|
||||
* For the moment, while we investigate which language identification library
|
||||
* we would like to use, keep this logic in sync with LanguageDetector.sys.mjs
|
||||
*/
|
||||
const DOC_TEXT_TO_IDENTIFY_LENGTH = 1024;
|
||||
|
||||
@ -199,10 +196,6 @@ export class LanguageIdEngine {
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to determine the language in which the document's content is written.
|
||||
*
|
||||
* For the moment, while we investigate which language identification library
|
||||
* we would like to use, keep this logic in sync with LanguageDetector.sys.mjs
|
||||
* @returns {string | null}
|
||||
*/
|
||||
async identifyLanguageFromDocument(document) {
|
||||
|
Loading…
Reference in New Issue
Block a user