docs(android): reconcile preview integration after #273 - #268
Conversation
b11d267 to
7245d59
Compare
|
Thank you for this — the scope and quality of work here is impressive. Rust v29 semantic oracle, ELF dependency audits, dual cgo mode testing, and a clear prerequisite stack show serious engineering. Before we dive into the review: have you seen our Android research discussion? https://github.com/orgs/gogpu/discussions/31 — it covers the "Minimal CGO Bootstrap" approach and community feedback. Would be good to know if your design aligns with or diverges from what we outlined there. We will review the full stack (#264–#269, goffi#62, and this PR), but this is 10K+ LOC across multiple repositories touching core lifecycle, surface ownership, and a new platform. We take responsibility for every line that lands in the codebase, so this will take some time to do properly. We'll work through the prerequisites first and come back to the Android implementation after that. Thanks again for the thorough work and for being upfront about the merge path and remaining physical-device gates. Pinging people who may be interested in Android support or whose review would be valuable: Team: @lkmavi — 5 prerequisite lifecycle fixes affect all backends including Metal. Your review on surface ownership (#269) especially welcome. wgpu contributors: @samyfodil @amery — lifecycle/surface changes in prerequisites touch areas you've contributed to. goffi contributors: @jiyeyuran @tie @pekim — goffi#62 adds Bionic/Android arm64 platform loader. Your perspective on the FFI layer changes welcome. Android interested (from discussion #31 and #18): @JanGordon @beikege @celer @SideFx — this is an Android implementation candidate. Your input and testing interest welcome. |
|
One more thought — since you're driving the Android implementation and have hands-on experience with the Go mobile toolchain + NDK, would you be interested in starting a discussion on r/golang about adding mobile platform support to a Pure Go GPU stack? The community there is large and this could attract developers and testers who have Android/iOS devices and experience with Go on mobile. Getting early feedback and testing help from the broader Go community would help us reach enterprise-quality faster. Just an idea — totally up to you. |
|
Yes, I read discussion #31. I think this implementation should align with the minimal-bootstrap direction, with one important boundary made explicit. Purego/goffi can replace cgo for outbound platform and Vulkan calls after startup; it does not replace Android's inbound process-entry/JNI boundary. A conventional Activity-hosted Go library still needs The direction I would recommend is therefore two layers:
I would keep WGPU/goffi buildable in both cgo modes where practical, but describe the modes precisely: cgo-disabled builds are useful library, headless, and toolchain evidence; the standard visible Activity route is currently a cgo-enabled final shared library. This avoids promising that Purego alone can manufacture an Android application entry point. The reference host should also prove the ownership ordering that matters in practice:
This keeps WGPU usable beneath GameActivity, gomobile, Ebitengine-style shells, custom embedders, and any future cgo-free host route. I would treat #268 as the reusable GPU layer and the minimal bootstrap as a follow-up example or small companion package, rather than expanding this PR to own Android application hosting. I am also happy to start the r/golang discussion. I think it will be most productive once there is a small runnable host prototype, so the post can offer a reproducible APK/device test and ask concrete questions instead of debating "Pure Go" in the abstract. |
|
We did a deep investigation into the CGO barrier on Android — all findings are posted in discussion #31. TL;DR: there are two blockers for zero-CGO Android — (1) purego's Would you be interested in authoring the Go proposal for |
|
One more thought related to the CGO barrier discussion above. Your verification section includes We've been working on eliminating this barrier through a pure-Go race detector. Honestly, this work fell off the radar for a while — the gogpu ecosystem (1.1M+ LOC across 15 repos) consumed all available bandwidth. But now that Android support is on the table, CGO-free race detection becomes directly relevant again — it's one of the three CGO barriers standing between Go and first-class Android support. Two approaches, actually: 1. Standalone tool (kolkov/racedetector, 46 stars, v0.8.5) — AST-level instrumentation, works today with 2. Runtime integration (kolkov/go-race, fork of golang/go) — this is the real solution. Hooks into compiler-generated This connects to the broader "CGO-free Go" story — three CGO barriers for Android development:
All three are being actively worked on. Together with @besmpl — the standalone racedetector can be used in your Android CI matrix right now for basic race coverage ( @lkmavi — this affects your Metal/macOS work too. Cross-compiled |
|
Yes — I’m interested. I would like to try to close the zero-CGO Android gap upstream, not merely document that it exists. After checking the current Go 1.26 toolchain, I think strict
So I agree that I’m willing to take a focused upstream spike on this:
If that spike shows a contained compiler/linker/runtime change, I am willing to implement it and author or co-author the proposal—not just file an aspirational issue. If it reveals a broad runtime redesign likely to consume years, we should say so honestly, publish the evidence, and retain the minimal cgo bootstrap as the practical route. Gogpu backing and review would make the proposal substantially stronger. This work should run in parallel with #268 rather than block it. The WGPU boundary remains useful either way: accept a caller-owned raw On race detection: I’m also happy to contribute reproducible WGPU/Hearth workloads and benchmark data. Two scope details are worth keeping precise:
The standalone detector can still be valuable as additional host and cgo-disabled coverage, and I’m willing to evaluate it without presenting it as equivalent to stock TSAN or physical-device evidence. I also read @dvyukov’s request as primarily asking for long-running, very-high-concurrency real workloads. Hearth is not a high-QPS server, but it can provide a different useful stress case: concurrent engine scheduling, resource lifetime changes, rendering submission, and repeated Android lifecycle transitions. So yes: let’s seriously test whether zero-CGO Android can be made real within a bounded upstream change. If it can, I’m in to build it. |
|
@kolkov — the bounded spike is green. The minimum zero-CGO Android native-entry primitive is real, and the implementation plus repro are now public. Short version: feasibility is no longer the blocker for the narrow Android/arm64 primitive. Hardening and upstream API/runtime design are. The successful path did not require a general scheduler or GC redesign. Public, pinned evidence
The Go change is an 18-file prototype, +273/-22, covering the Android/arm64 command policy, compiler export metadata, linker setup, shared-library startup, and foreign-thread runtime entry. The probe deliberately keeps the user ABI tiny: one fixed JNI symbol, primitive register-width values, and a small arm64 assembly adapter. This is evidence for a design, not a proposed final general-purpose API. What passedStock Go 1.26.4 still rejects the control at the expected boundary: The patched toolchain then built the same package with: The resulting artifact:
On an Android 11 / API 30 AOSP ATD arm64 emulator, What the emulator taught usIt found three real failures that host compilation could not:
The contained fixes were: guard that pre-G decoration path, distinguish Go-owned M stacks from callback-only M stacks, and use Android/arm64 This confirms our earlier conclusion: a Honest boundaryThis is not yet the complete Activity-hosted claim I outlined earlier. The cheap
So I would call this a contained feasibility proof, not production support. ReproduceThe linked recipe has the SDK/NDK and headless-emulator details. The core source pins are: git clone --branch besmpl/android-nativeexport-api30-repro --single-branch \
https://github.com/besmpl/go-android-cgo-free-prototype.git nativeexport-repro
git -C nativeexport-repro checkout --detach \
9033485b2ed5b3eff590063494f48d2ab40fc84a
git init patched-go
git -C patched-go remote add origin https://github.com/besmpl/go.git
git -C patched-go fetch --depth=1 origin \
d31f0b5f978859fd58f811b0c886818f7343d259
git -C patched-go checkout --detach FETCH_HEAD
(cd patched-go/src && ./make.bash)
export NATIVEEXPORT_GOROOT="$PWD/patched-go"
export ANDROID_NDK_HOME=/path/to/android-ndk-r29
export ANDROID_SDK_ROOT=/path/to/android-sdk
# Boot an arm64 API 29+ observer, then:
(cd nativeexport-repro && ./scripts/reproduce-minimum.sh)My recommended next sequence is:
This still should not block #268 or move Android hosting policy into WGPU. The raw caller-owned Thank you for pushing on the zero-CGO question, @kolkov. The answer from this first bounded experiment is: yes, the minimum mechanism is implementable; now it needs upstream design review and the missing lifecycle/device matrix. |
7245d59 to
153a1f0
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
486baef to
041e19e
Compare
|
@kolkov — thank you for insisting on prerequisite-first review, a minimal host boundary, and Rust-wgpu-shaped API parity. The stack is now in its intended review shape, and every current WGPU check—including patch coverage—is green. The important integration point is unchanged: please review and merge the prerequisites first; #268 should not merge with their replay commits still attached. I will do the cleanup rebases as each prerequisite lands. Final review graph
The five WGPU prerequisites and goffi#62 are independent candidates and can be reviewed in parallel. After they land and goffi is released, I will drop the five replay sequences from #268 and retain exactly its four Android-owned commits. webgpu#24 can land independently; #273 is replayed last and then retains exactly four parity-owned commits. Original authorship is preserved throughout. Current proof
The full canonical/replay map and exact reproduction command are now pinned in the #268 and #273 descriptions. The Android check also rejects desktop WSI, glibc sonames, standalone Boundary and remaining evidenceWGPU owns Vulkan/WSI from a caller-supplied Cross-build, ABI, ELF, emulator, and policy proof still do not equal representative physical-device evidence. API 29/API 36 startup and presentation, rotation, Activity recreation, repeated native-window replacement, and vendor/device coverage remain explicit release gates rather than claims in these PRs. We need this Android path badly for Hearth, and I am genuinely excited to do whatever follow-through makes it durable here: requested revisions, rebases, additional tests, device runs, and ongoing Android CI. None of the API or implementation is engine-specific, and maintainers should not have to untangle the temporary stack themselves. |
|
goffi v0.6.1 released — Android arm64 Bionic support is now available as a guarded preview. Release: https://github.com/go-webgpu/goffi/releases/tag/v0.6.1 This unblocks the next step in the merge path: #268 can now consume the canonical goffi release and drop the temporary CI pin. @besmpl has been added to goffi CODEOWNERS for Android paths. To be clear on scope: this is a guarded preview (API 29+), not full production Android support. Callbacks are explicitly rejected pending physical-device thread proof. Cross-build, ABI, and ELF gates pass on NDK r29 with Go 1.25.12 and Go 1.26.5 — but physical-device evidence remains the acceptance gate before we advertise Android as supported. We'll start reviewing the prerequisite stack (#264 → #265 → #266 → #267 → #269) next. |
|
Thank you — done.
I will wait for the planned prerequisite review order and drop/fold replay commits as those changes land rather than rewriting the stack prematurely. |
|
Follow-up evidence is now consolidated on That proof now covers:
Scope remains deliberate: the DNS/native-export harness is supporting feasibility and reproduction evidence, not code proposed for the @kolkov, this is the stable reproduction behind the Android claims here and the DNS row in discussion #31. All checks on this PR are currently green and it is mergeable; review remains the next gate. |
|
Progress update: all 5 prerequisites are merged, CI green on each.
We also reviewed and approved your other PRs in this session: #253 (MDI), #260 (Metal autorelease), #261 (Metal texture arrays), #263 (Metal ICB). #262 (DX12 state tracker) has request-changes — 5 test expectations need the missing field values, details on the review. We're currently merging #257, then #260 → #261 and #253 → #263. Once that merge queue finishes, please rebase #268 and #273 onto the updated Regarding CODEOWNERS: we plan to add you for |
|
All other PRs are now merged — #263 (Metal ICB), #262 (DX12 state tracker), #273 (typed SurfaceTarget). CI green on everything. #268 is the last one standing. It has merge conflicts across ~39 files from the prerequisite and feature merges — too many for automatic rebase. Could you rebase onto current |
13b59db to
3a7acf9
Compare
|
@kolkov — the requested rebase is done at |
Status
Ready to merge at exact head
3a7acf9fa217db2ee2bfd3d7b5223de66f47df30, directly on current WGPUmain(93fb27ff7ad717943e870580892b7490961a3ab7). The PR is conflict-free and GitHub reportsMERGEABLE/CLEAN. CI run 30080220791 is fully green, including both Android arm64 jobs.Rebase result
While resolving the requested rebase, I found that #273 had been squash-merged with the complete #268 Android stack still below its typed-surface commits. Its merge commit
93fb27ff7ad717943e870580892b7490961a3ab7explicitly includes:feat(vulkan): add Android arm64 WSI parity;ci(android): prove arm64 preview boundaries;docs(android): define the Vulkan preview contract;test(android): cover API 36 platform policy; andbuild(android): consume canonical goffi v0.6.1.I verified the result at the tree level: every file changed by #268's Android-owned range (
0eb4143..13b59db) is byte-identical between the old #268 head and currentmain. Replaying those commits would therefore duplicate code that is already merged rather than produce a reviewable Android delta.The clean rebase is consequently current
mainplus one focused documentation reconciliation commit. This preserves #268 as the original design/review record without manufacturing a duplicate implementation diff.What this PR now changes
mainthrough feat(surface): match Rust v29 typed surface targets #273;Implementation review location
The Android implementation to review is now in merge commit
93fb27f, with the design, ownership, API-floor, and evidence discussion retained in this PR. The relevant implementation remains inhal/vulkan/*android*,hal/vulkan/swapchain*,hal/allbackends/register_android.go, andscripts/check-android-arm64-preview.sh.Verification
All current GitHub checks pass:
Focused local verification also passed:
The historical Codecov bot comment predates this rebase and describes the old replay stack. The current PR changes documentation only and introduces no coverable Go lines.
Cross-build and binary-shape proof still do not substitute for representative hardware. API 29 and API 36 arm64 startup, known-color presentation, rotation, Activity recreation, repeated native-window replacement, and representative vendor/device coverage remain release-evidence gates rather than claims made here.