Repository navigation
Page translation: Update installed language packs when the manifest changes their version - #10953
Merged
Merged
Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
GerardPaligot
left a comment
Contributor
There was a problem hiding this comment.
@0nko Works as expected, I just have two comments covering rare edge cases. Depending on your thoughts, I'm happy to approve the PR as is or hold off, though I think they'd be worth fixing since the changes should be quick.
Member
Author
|
Thanks @GerardPaligot. I addressed both comments. |
GerardPaligot
approved these changes
Dec 4, 2026
GerardPaligot
left a comment
Contributor
There was a problem hiding this comment.
Happy to approve this contribution without additional comments, nice work!
0nko
enabled auto-merge
December 4, 2026 08:41
…ists a different version
… a pack an interrupted update swap left aside
…ith the emulator gotchas its run found
0nko
force-pushed
the
feature/ondrej/page-translate-update-pack
branch
from
December 4, 2026 16:29
a1eed59 to
7598342
Compare
0nko
disabled auto-merge
December 4, 2026 16:29
0nko
enabled auto-merge
December 4, 2026 16:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task/Issue URL: https://app.asana.com/1/137249556945/project/1207418217763355/task/1220716832050752?focus=true
Tech Design: https://app.asana.com/1/137249556945/project/1207418217763355/task/1220682435514957?focus=true
Evidence URL: https://artifacts.go.duckduckgo.com/view/auto/32d0fd9d-05ca-4988-bd91-fc0b332b566e/20261203-172523-page_translation_pack_update-446c/index.html
Why
A downloaded language pack stays on the version it was installed with, so a model fix or a rollback in the manifest never reaches people who already have the pack. This PR replaces an installed pack in the background when the manifest lists a different version for its pair.
What changed
LanguagePackScheduler.updateOutdatedqueues an update for every installed pack whose saved version differs from the manifest's. Each update goes into the pair's existing work chain, so it runs in order with that pair's downloads and deletes.LanguagePackUpdateWorkerdownloads and checks the new pack, then swaps it in throughTranslationEngine.replacePack. That waits until the pair's translator is unloaded, so a pack is never replaced while in use.moveIntoPlace). Downloads rename the pack into place, and updates swap it.Scope
pageTranslationparent flag and itstranslationsub-flag.Tradeoffs
.replaceddirectory during the swap, not to.old. Startup cleanup deletes.old, which would lose the pack if the process died between the two renames. The rerun worker restores.replacedinstead.Blast Radius
This only touches people who already downloaded a pack, and only when the manifest changes a pair's version. A failed update keeps the installed pack and gives up after three attempts without failing the pair's later operations.
Verification
Checks
An installed language pack whose saved version differs from the manifest's is replaced in the background after the next manifest fetch, translation still works with the new pack, and nothing is updated while the parent pageTranslation flag is off.
Verified: An installed language pack whose saved version differs from the manifest's is replaced in the background after the next manifest fetch, translation still works with the new pack, and nothing is updated while the parent pageTranslation flag is off. Driven through the app's UI on a sdk_gphone64_arm64 (API 36).
▶ Watch video · ▶ Watch video (part 2)
Key frames:
.
Outcome: Passes on this branch. All 10 checks passed.
Details:
prove.py, proof written for this change (source below), builds this branch (c57d10ad70), sdk_gphone64_arm64, API 36, live services: DuckDuckGo translation models CDN, es.wikipedia.org. Full reportUnverified: Swap while a translator of the pair is loaded (replacePack waiting for the translator to unload is covered by RealTranslationEngineTest; a device run cannot time it reliably.); Skipping the update on a metered network (The emulator network is unmetered; LanguagePackUpdateWorkerTest covers the metered skip.); Restoring a pack after a process death mid-swap (The window is two renames; LanguagePackUpdateWorkerTest covers the restore.).
All checks
Proof source
Rerun
Unit tests
Verified:
./gradlew :page-translation-impl:testDebugUnitTestpasses onc57d10ad70. The tests cover the metered skip, restoring a pack after an interrupted swap, keeping the installed pack when the swap fails, the parent flag, and the swap waiting for the translator to unload.Steps to test
pageTranslationandtranslation, then restart the app.adb shell run-as com.duckduckgo.mobile.android.debug cat files/page-translation/packs/es-en/manifest-entry.jsonshows the manifest's version again.