v161 · concept 3 · edge / limits
Memory & input limits
Chromium sets two parameters only on Android (components/on_device_translation/features.cc). First, a single translate() call may carry at most 256 KiB of UTF-8; anything bigger is rejected with QuotaExceededError. Second, a language pair that sits idle for one minute is unloaded to give back about 79–84 MiB. Neither limit shows up in inputQuota or measureInputUsage(), so a mobile page has to plan for them itself.
Translator is exposed…1 · count the bytes that matter
2 · run it against a pack that's already on the device
This section only creates a translator when availability() says available, so it never downloads anything. To install a pack deliberately, use Download on a constrained device.
3 · cold vs warm after the 1-minute idle unload
Time a short call now (warm). Then wait 65 seconds without using the translator and time the same call again. On Android, Chrome unloads the idle pair after 1 minute, so the second call includes reloading it. On desktop the timeout is 0 (never unload), so both calls should take about the same time.
the code
const ANDROID_MAX = 256 * 1024; // UTF-8 bytes per call
const bytes = (s) => new TextEncoder().encode(s).length; // NOT s.length (UTF-16 units)
translator.inputQuota; // Infinity, even on Android
await translator.measureInputUsage(text); // 0, even on Android
try { await translator.translate(huge); }
catch (e) { if (e.name === "QuotaExceededError") { /* e.requested, e.quota when exposed */ } }
for (const chunk of planChunks(text, ANDROID_MAX)) out.push(await translator.translate(chunk));