Skip to content

download mirror(just for Chinese) - #712

Open
kingokksa wants to merge 10 commits into
WinNative-Emu:mainfrom
kingokksa:feature/download-mirror
Open

download mirror(just for Chinese)#712
kingokksa wants to merge 10 commits into
WinNative-Emu:mainfrom
kingokksa:feature/download-mirror

Conversation

@kingokksa

Copy link
Copy Markdown
Contributor

feat(steam-cdn): show China CDN toggle only for Chinese locale, default on
fix(crash): load libwnsteam before static setUseChinaCdn
feat(steam): toggle for Steam-China-only CDN servers in Downloads tab
feat(mirror): show mirror toggle only for Chinese locale, default on
fix(mirror): wizard toggle wrote wrong prefs file; mirror list fetch too
feat(ui): mirror toggle in wizard install-all row + align settings card colors
feat(settings): wrap GitHub downloads with China accelerator proxy
feat(settings): China mirror toggle for WinNative-Components downloads
feat(settings): user-configurable GitHub download mirror base

Components/containers in the setup wizard download from GitHub
(nicholasx417/WinNative-Components) which is unreachable on some networks.
Add a 'Download Source (GitHub Mirror)' entry in Other settings: fill a
mirror base (e.g. https://gitee.com/yourname) and the wizard rewrites
github.com release URLs and raw.githubusercontent.com file URLs through it
(gitee keeps /releases/download/{tag}/{file} and /raw/{branch}/{path}).
Empty = GitHub direct. Wired into SetupWizard component downloads and the
default.json manifest fetch.
Replace the free-text mirror base with a 'use_china_mirror' toggle
(default off) pointing at the user's Gitee fork
(gitee.com/kingokksa/winnative-components-cnfork). Because the fork repo
is renamed, the rewrite maps the GitHub repo path wholesale
(github.com/nicholasx417/WinNative-Components -> mirror base) instead of a
plain host/owner prefix swap, and raw.githubusercontent URLs become
{base}/raw/{branch}/{path}. Input-control profiles now also honor the
mirror. Other GitHub repos (Retro-Consoles, drivers) are untouched.
Replace the Gitee-fork mirroring with a simpler GitHub proxy prefix: when
'use_china_mirror' is on, any https://github.com or raw.githubusercontent.com
URL becomes {proxyBase}/<url>. Default proxy gh-proxy.com, editable in
Settings (Other). Original URLs untouched when off; non-GitHub repos
unaffected. No release/asset migration needed.
…rd colors

Add a 'Mirror' switch left of 'Install All Recommended' in the setup
wizard, sharing the same use_china_mirror pref as Other settings (kept in
sync). Toggling re-runs refreshRecommendedPackageCache so the recommended
list re-fetches through the new download source. Also style the Other
settings DownloadSource card with the same palette as its neighbours
(CardDark/CardBorder/IconBoxBg/Accent/TextPrimary/TextSecondary).
SetupWizardActivity.prefs() returns a custom PREFS_NAME file, but
DownloadSource mirrors via PreferenceManager.getDefaultSharedPreferences.
The wizard's Mirror switch therefore wrote use_china_mirror into the wrong
store: it never affected downloads (still GitHub original) and reset to off
after refresh. Write the DEFAULT prefs instead so both switches share one
pref. Also route the component catalog fetch (ContentsManager.REMOTE_PROFILES)
through the mirror so the list itself uses the accelerated source. Debug
log-level change now restarts logcat capture on a background thread so it
can't ANR/crash.
Mirror toggle (settings card + wizard switch) is hidden for non-Chinese
systems and defaults to enabled for Chinese (zh-*) until explicitly toggled.
zh-TW strings added.
The native depot downloader filters out steam_china_only content servers,
so the in-Steam download-region setting never applies to it. Add a
Downloads-tab toggle (default off) that sets a native flag keeping
China-only CDN servers in the usable server list. Wired: PrefManager
steamUseChinaCdn (persisted), WnSteamSession.setUseChinaCdn -> JNI
nativeSetUseChinaCdn -> depot_downloader::USE_CHINA_CDN global, applied at
app start and live on toggle.
setUseChinaCdn calls a static native method, but PluviaApp.onCreate
invokes it before any WnSteamSession exists, so libwnsteam.so was not
loaded yet -> UnsatisfiedLinkError on every app start. Load the lib via
WnSteamClient.ensureLoaded() first and wrap in runCatching so a missing
lib can never crash startup.
…lt on

Matches the GitHub-mirror behavior: toggle hidden for non-Chinese systems
and enabled by default for Chinese (zh-*) until explicitly toggled.
@kingokksa
kingokksa force-pushed the feature/download-mirror branch from 8ff1196 to 39b4354 Compare August 30, 2026 03:01
@maxjivi05

Copy link
Copy Markdown
Contributor

I built this and ran it on a device against main. The connectivity problem you're solving is real, but there are a few blocking issues.

1. This moves UI for users who aren't affected by the feature. The Install-All row changed from a Box(contentAlignment = CenterEnd) to a Row. For Chinese locales your Spacer(weight(1f)) keeps the button on the right, but for everyone else the if is skipped and Row falls back to Arrangement.Start — so "Install All Recommended" jumps from the right edge to the left edge for every non-Chinese user. Moving the Spacer(weight(1f)) outside the if fixes it.

2. The Steam China CDN switch doesn't work. On device it renders as clickable, but tapping it does nothing — the checked state never changes and it's still on after restarting the app. I think it's because checked = PrefManager.steamUseChinaCdn reads SharedPreferences directly, which isn't observable state, so nothing tells Compose to recompose. Your other two switches (the wizard one and the settings card) are wired correctly with local state and don't have this problem. Something like var enabled by remember { mutableStateOf(PrefManager.steamUseChinaCdn) } should sort it.

3. Traditional Chinese is missing the new Steam CDN strings. values-zh-rTW got the download-source strings but not steam_download_use_china_cdn / _summary. Since isChineseLocale() matches any zh-*, zh-TW users see that toggle in English while the rest of the screen is Chinese.

4. The strings say "Off by default" but both toggles default to on. steamUseChinaCdn and chinaMirrorEnabled both fall back to isChineseLocale(), so on a Chinese device they're enabled out of the box — right next to text saying "默认关闭 / Off by default". Please make the copy and the behaviour agree.

5. There's unreachable code in DownloadSource.kt. Nothing in the repo ever writes download_source_base, so customBase() always returns empty and the whole raw.githubusercontent → {base}/{owner}/{repo}/raw/... branch can never run. It's left over from the earlier Gitee approach — worth deleting before this lands.

6. Once it's on, a locale change makes it unreachable. Both toggles persist, but both UIs are hidden behind isChineseLocale(). If someone enables the mirror and later switches their phone to English, downloads keep going through the proxy with no setting anywhere to turn it off. Maybe only hide the control when the pref is still at its default.

One thing I'd like a maintainer decision on before merging: with the mirror on, component downloads (Wine/Proton builds, DXVK, imagefs) go through a third-party proxy, and there's no checksum or signature check anywhere in that path — RemotePackageSpec is just (type, verName, remoteUrl). Combined with it being on by default and the base being a free-text field, that means whoever operates that host can serve anything. Publishing SHA-256 in default.json and verifying after download would fix it for the direct-GitHub path too.

Also worth knowing: drivers, retro cores and the in-app updater still go to GitHub directly, so a user with this on may still be unable to download those.

Could you post screenshots of: the wizard Recommended tab in English (to show the button position after your fix), the Downloads tab with the CDN toggle being turned off and staying off after an app restart, and the Downloads tab in zh-TW once the strings are added?

Finally — the Steam CDN work and the GitHub mirror are independent features and would be much easier to review as two PRs. The description is also a list of nine commit subjects, several describing approaches that were later replaced (the Gitee fork, the free-text base, and a logcat change that isn't in the diff at all). Worth rewriting before merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants