mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-17 23:13:22 +09:00
271 lines
117 KiB
Markdown
271 lines
117 KiB
Markdown
# Anland × MobileGL: buffer, synchronization, process and integration study
|
||
|
||
Research date: 2026-09-30. This is a source audit, not a device validation. All audited checkouts were clean; exact revisions are in the table below. Repository citations link to those revisions. Citations of third-party material that was snapshotted during the audit (Xwayland, drm_fourcc.h, Mesa/Termux build files, libwayland, the AHB header, Anland issues/PRs) link to the upstream source at the snapshotted revision; `refs/heads/main` links (the Android header) may have drifted since 2026-09-30. Statements marked **inferred** are architectural conclusions or proposed changes, not implemented behavior.
|
||
|
||
| Tree | Audited revision | Scope |
|
||
|---|---|---|
|
||
| `SuperTurtleDev_anland` | `cc1691805fe6aca6851b6fcccb6a1e33019026c1` | Current 6.x main |
|
||
| `SuperTurtleDev_anland-shell` | `920fcfc8159690f5232e2d9c7c3294d4c1481145` | Droidspaces launcher |
|
||
| `lfdevs_anland-termux` | `a70879f059a2e8439fdb132195c3dd10d4810106` | Legacy-derived Termux integration |
|
||
| `E7G_wlroots-anland` | `351399132de0b208ddb36d0ea2fa74cbe668fb72` | Private-protocol wlroots backend |
|
||
| `asveroid_anland-plasma-termux` | `099710d413b47d2f3f8c5091a95ee2732d3be0e6` | Termux Plasma installer |
|
||
| `Yizhou147_anland-drm` | `850f7ca0e0f25d34dd04baa7e12e8751bcff4951` | Experimental DRM consumer |
|
||
| `SuperTurtleDev_anland_legacy` | `9ab13eb146bc9f3dd3cc44cabc268659d9eb0a46` | 5.x comparison |
|
||
|
||
Main explicitly identifies itself as the 6.x rewrite and explains that 5.x used a private display protocol requiring compositor-specific backends. Do not apply Termux/5.x results automatically to waylandbridge 6.x. [anland/README.md:9–25](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/README.md#L9-L25>) [Termux/README.md:7–13](<https://github.com/lfdevs/anland-termux/blob/a70879f059a2e8439fdb132195c3dd10d4810106/README.md#L7-L13>)
|
||
|
||
## Decision in brief
|
||
|
||
**Inferred:** MobileGL can supply rendering to Anland, but successful GL command execution is only half the integration. Current 6.x needs either a `wl_shm` buffer or its narrow raw-dma-buf representation. It does **not** currently expose a native AHardwareBuffer producer import API. The best path for an Android render server is an added native-AHB buffer ingress that preserves the complete gralloc handle, with Wayland buffer lifetime and sync-file fences carried alongside it. The existing Android rendering side already imports AHBs as EGLImages and submits AHBs to SurfaceControl. [waylandbridge/awl_server.c:385–401](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_server.c#L385-L401>) [waylandbridge/awl_internal.h:65–81](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_internal.h#L65-L81>) [waylandbridge/awl_gl.cpp:257–289](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_gl.cpp#L257-L289>) [waylandbridge/awl_sc.cpp:727–743](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L727-L743>)
|
||
|
||
The highest-impact findings are:
|
||
|
||
- dma-buf is **v3, one plane, AR24/XR24**, with no device feedback. Native RGBA8888/DRM ABGR8888 is outside that format list. [waylandbridge/awl_dmabuf.c:17–22](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_dmabuf.c#L17-L22>) [waylandbridge/awl_dmabuf.c:105–127](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_dmabuf.c#L105-L127>) [waylandbridge/awl_dmabuf.c:212–237](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_dmabuf.c#L212-L237>) [drm-uapi/drm_fourcc.h:193–199](https://github.com/lfdevs/mesa-for-android-container/blob/98f3d6229d61452cef80f8563af7c56ae599dc14/include/drm-uapi/drm_fourcc.h#L193-L199)
|
||
- The actual local `DRM_FORMAT_MOD_INVALID` constant is **wrong relative to DRM UAPI**: `0x00ffffff00000000ULL`, versus UAPI `0x00ffffffffffffff`. Linear `0` is unambiguous. [waylandbridge/awl_internal.h:35–40](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_internal.h#L35-L40>) [drm-uapi/drm_fourcc.h:467–492](https://github.com/lfdevs/mesa-for-android-container/blob/98f3d6229d61452cef80f8563af7c56ae599dc14/include/drm-uapi/drm_fourcc.h#L467-L492) [drm-uapi/drm_fourcc.h:527–544](https://github.com/lfdevs/mesa-for-android-container/blob/98f3d6229d61452cef80f8563af7c56ae599dc14/include/drm-uapi/drm_fourcc.h#L527-L544)
|
||
- Both dma-buf rendering modes depend on a **Qualcomm snapalloc-style donor forge**. A GPU-copy fallback for pitch or pacing still needs the forge to succeed; it is not a generic fallback for unknown gralloc layouts. [waylandbridge/awl_ahb.cpp:139–146](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L139-L146>) [waylandbridge/awl_ahb.cpp:325–340](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L325-L340>) [waylandbridge/awl_sc.cpp:903–935](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L903-L935>)
|
||
- The “statically-linked ELF” description does not mean a fully static graphics stack: the target links Android `EGL`, `GLESv3`, `nativewindow`, `android`, and `binder_ndk`. [anland/README.md:73–78](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/README.md#L73-L78>) [waylandbridge/CMakeLists.txt:303–308](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/CMakeLists.txt#L303-L308>) [waylandbridge/CMakeLists.txt:364–365](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/CMakeLists.txt#L364-L365>)
|
||
|
||
## 1. Buffer ingress contract and the complete dma-buf path
|
||
|
||
### 1.1 What the Wayland endpoint advertises and accepts
|
||
|
||
| Item | Exact current behavior |
|
||
|---|---|
|
||
| Core compositor | `wl_compositor` **v4**. [waylandbridge/awl_surface.c:1110–1120](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_surface.c#L1110-L1120>) |
|
||
| Shared memory | The pinned libwayland's `wl_display_init_shm()` creates `wl_shm` **v2** and supplies ARGB8888 and XRGB8888. Anland adds no extra formats in server initialization. In `wl_shm` these are **0 and 1**, not DRM fourcc values. [waylandbridge/awl_server.c:385–401](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_server.c#L385-L401>) [libwayland/wayland-shm.c:451–475](https://github.com/SuperTurtleDev/libwayland/blob/37032ecd5bf7657629b9d9725c084025497840d9/src/wayland-shm.c#L451-L475) [waylandbridge/awl_surface.c:1155–1160](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_surface.c#L1155-L1160>) |
|
||
| dma-buf global | `zwp_linux_dmabuf_v1` **v3**, with client binds capped at 3. Only `destroy` and `create_params` are implemented on the factory. [waylandbridge/awl_dmabuf.c:212–237](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_dmabuf.c#L212-L237>) |
|
||
| dma-buf formats | `AWL_FORMAT_ARGB8888 = fourcc('A','R','2','4')` and `AWL_FORMAT_XRGB8888 = fourcc('X','R','2','4')`; little-endian memory is `[B,G,R,A]` or `[B,G,R,X]`. No AB24/XB24, RGB565, YUV or multi-plane video format. [waylandbridge/awl_internal.h:29–33](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_internal.h#L29-L33>) [waylandbridge/awl_dmabuf.c:17–22](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_dmabuf.c#L17-L22>) [waylandbridge/awl_dmabuf.c:54–57](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_dmabuf.c#L54-L57>) |
|
||
| Advertised modifiers | Each format has entries named `DRM_FORMAT_MOD_INVALID` and `DRM_FORMAT_MOD_LINEAR`. The former is locally defined as **`0x00ffffff00000000ULL`**, the latter as **`0ULL`**. Bind sends `format` for every entry, so the two formats are each announced twice; modifier events are conditional on protocol version. [waylandbridge/awl_dmabuf.c:17–22](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_dmabuf.c#L17-L22>) [waylandbridge/awl_dmabuf.c:217–229](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_dmabuf.c#L217-L229>) [waylandbridge/awl_internal.h:35–40](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_internal.h#L35-L40>) |
|
||
| Planes and offset | Only `plane_idx == 0`; other planes close the supplied fd and post `ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_IDX`. Repeated plane-0 `add` overwrites the previous fd. **Offset is ignored**, not validated or retained. [waylandbridge/awl_dmabuf.c:105–127](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_dmabuf.c#L105-L127>) |
|
||
| Feedback / device | No `get_default_feedback`, `get_surface_feedback`, feedback object, format-table/tranche events, or `main_device`/`dev_t` advertisement in this v3 implementation. This is absence of a device advertisement, not a zero-valued or fabricated `dev_t`. The Xwayland patch explicitly compensates for it. [waylandbridge/awl_dmabuf.c:212–237](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_dmabuf.c#L212-L237>) [anland/patches/xwayland/README.anland.md:29–39](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/patches/xwayland/README.anland.md#L29-L39>) |
|
||
|
||
**Modifier mismatch:** DRM UAPI defines INVALID as `fourcc_mod_code(NONE, DRM_FORMAT_RESERVED)`, with `NONE=0` and `DRM_FORMAT_RESERVED=((1ULL<<56)-1)`. Thus the advertised nonzero value in Anland is not standard INVALID. **Inferred:** a client that compares exact modifier values can reject/misinterpret it. However, Anland's creation path itself does not reject an unadvertised modifier: it only passes the value into logging, then discards it from the persistent buffer wrapper. Therefore “only linear supported” is the intended usable layout, **not a correctly enforced request validator**. [drm-uapi/drm_fourcc.h:467–492](https://github.com/lfdevs/mesa-for-android-container/blob/98f3d6229d61452cef80f8563af7c56ae599dc14/include/drm-uapi/drm_fourcc.h#L467-L492) [drm-uapi/drm_fourcc.h:527–544](https://github.com/lfdevs/mesa-for-android-container/blob/98f3d6229d61452cef80f8563af7c56ae599dc14/include/drm-uapi/drm_fourcc.h#L527-L544) [waylandbridge/awl_internal.h:35–40](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_internal.h#L35-L40>) [waylandbridge/awl_dmabuf.c:49–85](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_dmabuf.c#L49-L85>)
|
||
|
||
### 1.2 From `create` / `create_immed` to a displayed frame
|
||
|
||
1. **Protocol creation:** `params_add` records one fd, byte stride and modifier; `create`/`create_immed` require an fd and positive width/height. `dmabuf_buffer_create` rejects formats outside AR24/XR24, takes the fd, records its inode with `fstat`, and constructs a `wl_buffer`. There is no EGL/gralloc import at this stage. `create` sends `created` or `failed`; `create_immed` creates the requested object or posts `INVALID_WL_BUFFER`. Both ignore the `flags` argument. [waylandbridge/awl_dmabuf.c:49–85](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_dmabuf.c#L49-L85>) [waylandbridge/awl_dmabuf.c:105–175](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_dmabuf.c#L105-L175>)
|
||
2. **Commit:** `awl_surface_apply_buffer` duplicates the dma-buf fd, takes the explicit acquire fence or snapshots implicit write completion with `awl_dmabuf_export_sync_file`, copies geometry/format into `struct awl_bq_buffer`, and references the `awl_buffer` through an `awl_bufref` release cookie. A full queue returns/drops the new frame immediately. Destroying the protocol buffer does not invalidate already queued frames, which hold their own fd and wrapper references. [waylandbridge/awl_surface.c:184–218](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_surface.c#L184-L218>) [waylandbridge/awl_dmabuf.c:33–46](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_dmabuf.c#L33-L46>) [waylandbridge/awl_bufferqueue.h:63–76](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_bufferqueue.h#L63-L76>)
|
||
3. **Queue:** mailbox-like draining drops superseded heads only while the next element is ready, assuming FIFO completion. The retained head and consumer references determine lifetime; the last reference runs the release callback and closes its owned fds. Capacity is **8** elements, including the head. [waylandbridge/awl_bufferqueue.c:43–48](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_bufferqueue.c#L43-L48>) [waylandbridge/awl_bufferqueue.c:201–210](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_bufferqueue.c#L201-L210>) [waylandbridge/awl_bufferqueue.c:379–388](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_bufferqueue.c#L379-L388>)
|
||
4. **AHB resolution:** each layer has an eight-slot cache. Its key is **`(ino,width,height,stride)`**, not modifier or format. A miss calls `awl_ahb_wrap`; a hit reuses the registered AHB and, for GL, its EGLImage/texture payload. A failed forge leaves the cache unchanged for a later retry. [waylandbridge/awl_ahb.hpp:53–69](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.hpp#L53-L69>) [waylandbridge/awl_ahb.cpp:534–569](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L534-L569>)
|
||
5. **EGL renderer:** ready dma-buf → forged AHB → `eglGetNativeClientBufferANDROID` → `eglCreateImageKHR(..., EGL_NATIVE_BUFFER_ANDROID, ...)` → `glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, ...)` → per-window GPU composition → `eglSwapBuffers`. A missing texture skips that layer; no direct `EGL_LINUX_DMA_BUF_EXT` fallback is attempted here. [waylandbridge/awl_renderer.cpp:292–323](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_renderer.cpp#L292-L323>) [waylandbridge/awl_gl.cpp:257–289](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_gl.cpp#L257-L289>) [waylandbridge/awl_renderer.cpp:382–419](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_renderer.cpp#L382-L419>)
|
||
6. **SurfaceControl renderer:** `enum sc_mode { SC_MODE_NONE=0, SC_MODE_SCANOUT, SC_MODE_EGL, SC_MODE_EGL_SHM }`. `SCANOUT` submits the forged client AHB through `ASurfaceTransaction_setBuffer[WithRelease]`. `EGL` samples that forged AHB into a platform-allocated AHB for this layer. `EGL_SHM` uploads shared-memory pixels into a texture and blits into such a target. Every Wayland layer becomes a SurfaceControl sibling. **Inferred:** the name `SCANOUT` describes Anland's zero-copy submission; actual HWC-plane assignment remains SurfaceFlinger's decision. [waylandbridge/awl_sc.cpp:1–30](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L1-L30>) [waylandbridge/awl_sc.cpp:358–364](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L358-L364>) [waylandbridge/awl_sc.cpp:727–743](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L727-L743>) [waylandbridge/awl_sc.cpp:903–975](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L903-L975>)
|
||
|
||
### 1.3 What the forge actually does
|
||
|
||
The source describes a specific Qualcomm **snapalloc** layout: native handle **fd[0] = pixel dma-buf, fd[1] = metadata blob**, observed as about **28 KiB**. It explains that a container KGSL dma-buf lacks that descriptor and a bare `GB01+fd` import was rejected. `donor_blob_fd` explicitly refuses a donor unless `numFds == 2`. This is not a vendor-neutral construction of an AHB from any dma-buf. [waylandbridge/awl_ahb.cpp:5–28](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L5-L28>) [waylandbridge/awl_ahb.cpp:139–146](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L139-L146>)
|
||
|
||
Calibration allocates BGRA donors of **300×300** and **1134×567**, both with `AWL_AHB_DONOR_USAGE = AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE`. It reads allocator-reported stride and pixel-allocation size, mmaps their metadata blobs, and locates geometry/size fields by comparing the two layouts. Blob sizes must agree and be positive; native-handle integer counts must agree and be at most **64**. It requires recognized stride-in-pixels, stride-in-bytes, height, allocation/exact size, extent and native-handle integer fields; failure reports **“vendor layout changed, refusing to forge.”** [waylandbridge/awl_ahb.hpp:19–23](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.hpp#L19-L23>) [waylandbridge/awl_ahb.cpp:172–220](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L172-L220>) [waylandbridge/awl_ahb.cpp:223–274](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L223-L274>)
|
||
|
||
`awl_ahb_wrap` serializes calibration/import with a mutex and hardcodes **`AWL_HAL_BGRA_8888 = 5`**. It reuses an existing matching-geometry AHB as donor, without modifying its live blob, or allocates a **4×4** donor. It patches the cold donor's blob and integer payload to client geometry, **`stride/4`** and **`stride*height`**. Both calibrated allocation-size and exact-size metadata fields are set to that product; this path does not query or validate the actual client dma-buf extent. [waylandbridge/awl_geom.h:42–51](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_geom.h#L42-L51>) [waylandbridge/awl_ahb.cpp:300–320](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L300-L320>) [waylandbridge/awl_ahb.cpp:325–395](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L325-L395>)
|
||
|
||
It then fabricates the Android `GraphicBuffer::flatten` representation: **13 int32 header words**, magic **`0x47423031` (`GB01`)**, width/height/stride/HAL format, layer count **1**, usage words, synthetic buffer id with **bit 63 set**, generation **0**, **two fds**, and the donor's integer count. A local `AF_UNIX/SOCK_STREAM` socketpair carries the flattened bytes plus `SCM_RIGHTS` containing **`dup(client_pixel_fd)` and `dup(donor_blob_fd)`**. `AHardwareBuffer_recvHandleFromUnixSocket` reconstructs/registers the AHB through Android/gralloc. That socketpair is entirely inside the daemon; it is **not** a client-facing native-AHB transport. [waylandbridge/awl_ahb.cpp:398–480](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L398-L480>)
|
||
|
||
### 1.4 Usable layout preconditions versus checks that are actually implemented
|
||
|
||
| Condition | What is checked / practical implication |
|
||
|---|---|
|
||
| Format | Protocol admits only AR24/XR24; forge always describes HAL BGRA8888. RGBA8888 is DRM **AB24**, so simply relabeling it AR24 swaps red/blue. [waylandbridge/awl_dmabuf.c:54–57](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_dmabuf.c#L54-L57>) [waylandbridge/awl_ahb.cpp:334–336](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L334-L336>) [drm-uapi/drm_fourcc.h:193–199](https://github.com/lfdevs/mesa-for-android-container/blob/98f3d6229d61452cef80f8563af7c56ae599dc14/include/drm-uapi/drm_fourcc.h#L193-L199) |
|
||
| Linear, zero-offset data | Offset is ignored and modifier is not kept in `awl_buffer` or the queue. **Inferred:** correct pixels require the simple packed layout described by the forge; arbitrary tiling/compression cannot be represented by supplying an fd alone. [waylandbridge/awl_dmabuf.c:105–127](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_dmabuf.c#L105-L127>) [waylandbridge/awl_internal.h:71–81](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_internal.h#L71-L81>) [waylandbridge/awl_bufferqueue.h:63–76](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_bufferqueue.h#L63-L76>) |
|
||
| Dimensions / byte extent | Only `width>0,height>0` are validated at request time. There is no request-time `stride>=width*4`, overflow, actual-fd-size or maximum-texture-size check in this constructor. **Inferred:** the client must provide sufficiently large storage with sane geometry; protocol creation success does not establish import or sampling safety. [waylandbridge/awl_dmabuf.c:49–85](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_dmabuf.c#L49-L85>) [waylandbridge/awl_dmabuf.c:130–175](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_dmabuf.c#L130-L175>) [waylandbridge/awl_ahb.cpp:377–395](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L377-L395>) |
|
||
| Byte stride | Forge converts with integer `stride/4`. Scanout rejects a stride not divisible by 4; that is not a universal ingress rejection. **Inferred:** valid packed-32-bit buffers should use a stride divisible by 4 and at least width×4. [waylandbridge/awl_ahb.cpp:87–91](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L87-L91>) [waylandbridge/awl_ahb.cpp:377–395](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L377-L395>) |
|
||
| HWC-compatible stride | Let `p = stride/4`. `awl_ahb_hwc_scanout_ok` probes allocator stride for **width p**, height **64**, BGRA and donor usage. It accepts if the returned pitch equals p, or if the probe returns **0** (no verdict, keep HWC). It does not merely compare allocator stride at the buffer's logical width. [waylandbridge/awl_ahb.cpp:60–91](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L60-L91>) |
|
||
| Non-fixed-point pitch | Forces a GPU blit into a platform allocation. The source documents pitch **1024 px → gralloc 1280 px** causing DRM `ADDFB2` failure/blank HWC output while GPU composition/screenshots looked correct. The forge must still succeed for that source texture. [waylandbridge/awl_sc.cpp:22–30](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L22-L30>) [waylandbridge/awl_sc.cpp:903–935](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L903-L935>) |
|
||
| Unsupported donor layout | Wrong fd count, unrecognized metadata, mmap/allocation/import failure → `NULL`, log, blank/skipped or old retained layer. There is no generic CPU upload fallback in the audited main. [waylandbridge/awl_ahb.cpp:139–146](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L139-L146>) [waylandbridge/awl_ahb.cpp:264–274](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L264-L274>) [waylandbridge/awl_ahb.cpp:337–340](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L337-L340>) [waylandbridge/awl_renderer.cpp:295–323](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_renderer.cpp#L295-L323>) [waylandbridge/awl_sc.cpp:729–735](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L729-L735>) |
|
||
|
||
**Already-gralloc-allocated input:** extracting only its pixel fd and submitting it through linux-dmabuf still enters this forge; the original gralloc metadata and complete native handle never reach the renderer. There is no detection of “this came from gralloc, use its original handle.” **Inferred:** a genuinely linear BGRA allocation with compatible pitch might happen to work, but native allocation provenance alone is no guarantee. A compressed native allocation is especially unsuitable for this reconstruction. [waylandbridge/awl_internal.h:71–81](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_internal.h#L71-L81>) [waylandbridge/awl_ahb.cpp:422–464](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L422-L464>) [waylandbridge/awl_ahb.cpp:562–569](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L562-L569>)
|
||
|
||
**UBWC/compression:** neither supported modifier list names a Qualcomm compressed modifier; no modifier or compression metadata survives in the queue. The donor path assumes the sampled BGRA layout, but contains no general UBWC detection, decompressor, or universal vendor “disable compression” operation. **Inferred:** compression is excluded from the usable raw-dma-buf contract, although the request handler fails to enforce that exclusion. `DRM_FORMAT_MOD_INVALID` must not be treated as permission to send an opaque compressed AHB pixel fd. A later GPU copy does not solve this: first it must import/sample the source correctly. [waylandbridge/awl_dmabuf.c:17–22](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_dmabuf.c#L17-L22>) [waylandbridge/awl_dmabuf.c:49–85](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_dmabuf.c#L49-L85>) [waylandbridge/awl_bufferqueue.h:63–76](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_bufferqueue.h#L63-L76>) [waylandbridge/awl_ahb.cpp:334–395](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L334-L395>) [waylandbridge/awl_sc.cpp:922–930](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L922-L930>)
|
||
|
||
**Native-handle ingress today:** none in the audited buffer factory/global list or Binder transaction table. Binder `T_CONNECT=18` transfers a Wayland **connection socket**; `T_SURFACE=1` transfers an Android **destination Surface**. Neither submits a producer AHardwareBuffer. The sole `recvHandleFromUnixSocket` in the frame-import path consumes the daemon's fabricated local wire message. [waylandbridge/awl_server.c:385–401](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_server.c#L385-L401>) [waylandbridge/waylandbridge.cpp:140–197](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/waylandbridge.cpp#L140-L197>) [libawl/AwlClient.java:80–95](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/app/libawl/src/main/java/com/anlandnext/awl/AwlClient.java#L80-L95>) [libawl/AwlClient.java:335–381](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/app/libawl/src/main/java/com/anlandnext/awl/AwlClient.java#L335-L381>) [waylandbridge/awl_ahb.cpp:444–464](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L444-L464>)
|
||
|
||
**External evidence, not merged behavior:** draft PR [#92](https://github.com/SuperTurtleDev/anland/pull/92), open and unmerged when retrieved, reports black Nautilus/Kitty/Chromium content on Snapdragon 870/Adreno 650 with `sc_enabled=0`; its sample is AR24 **2024×1344, stride 8192, modifier 0**, with nonzero CPU-mappable pixels but forge failure. The proposal adds synchronized mmap/CPU upload. It is not present in the audited main and is explicitly limited to linear packed data. [anland PR #92](https://github.com/SuperTurtleDev/anland/pull/92) [anland PR #92](https://github.com/SuperTurtleDev/anland/pull/92) [anland PR #92](https://github.com/SuperTurtleDev/anland/pull/92)
|
||
|
||
Android service access can also fail more severely than a returned import error: closed issue [#84](https://github.com/SuperTurtleDev/anland/issues/84) reports a 6.1.2 process abort inside `AHardwareBuffer_allocate`, with **“Failed to load matching allocator for mapper version 4”** and allocator/mapper service-discovery denials. Current policy contains the corresponding mapper/allocator `find` grants. This is historical device evidence, not a claim that the same defect remains unfixed in the audited revision. [anland issue #84](https://github.com/SuperTurtleDev/anland/issues/84) [anland/module/sepolicy.rule:159–161](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/sepolicy.rule#L159-L161>)
|
||
|
||
## 2. Synchronization and buffer release
|
||
|
||
### 2.1 Protocol and producer completion
|
||
|
||
The implemented protocol is **`zwp_linux_explicit_synchronization_v1` v2**, using per-commit Linux **sync_file fds**. `set_acquire_fence` validates with `SYNC_IOC_FILE_INFO`, rejects invalid fds and duplicate pending fences, and stores `pend_acquire_fd`. `get_release` creates a `zwp_linux_buffer_release_v1` object. Commit validation rejects acquire/release without an attached buffer; an acquire fence on `wl_shm` is `UNSUPPORTED_BUFFER`, although requesting a release object alone for shm is permitted. Sync-subsurface latching moves fence/release state with the buffer. [waylandbridge/awl_esync.c:1–26](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_esync.c#L1-L26>) [waylandbridge/awl_esync.c:121–170](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_esync.c#L121-L170>) [waylandbridge/awl_esync.c:179–200](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_esync.c#L179-L200>) [waylandbridge/awl_esync.c:265–277](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_esync.c#L265-L277>) [waylandbridge/awl_bufferqueue.c:175–179](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_bufferqueue.c#L175-L179>)
|
||
|
||
No **linux-drm-syncobj** global is registered or implemented by waylandbridge. The XML comment saying the older explicit-sync protocol is superseded is not an implementation of its successor. In particular, the pinned Xwayland source has its own syncobj-related code; that does not mean the Anland compositor advertises it. [waylandbridge/awl_server.c:385–401](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_server.c#L385-L401>) [waylandbridge/CMakeLists.txt:309–349](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/CMakeLists.txt#L309-L349>) [waylandbridge/protocols/linux-explicit-synchronization-unstable-v1.xml:39](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/protocols/linux-explicit-synchronization-unstable-v1.xml#L39>) [xserver/hw/xwayland/xwayland-glamor-gbm.c:1788–1797](https://gitlab.freedesktop.org/xorg/xserver/-/blob/5a873951579f1ff894f71489f3651a55d6dde250/hw/xwayland/xwayland-glamor-gbm.c#L1788-1797)
|
||
|
||
| Consumer path | Acquire fence handling |
|
||
|---|---|
|
||
| Whole-window EGL renderer | Calls `awl_bufferqueue_gethead(q,100)`. This is a CPU `poll`; **100 ms is only a warning threshold**. On timeout it waits again with **`-1`**, i.e. indefinitely, before sampling. A real wait error logs and can return the head anyway. Header descriptions calling the wait “bounded” are incomplete compared with this body. [waylandbridge/awl_renderer.cpp:276–279](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_renderer.cpp#L276-L279>) [waylandbridge/awl_bufferqueue.c:121–137](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_bufferqueue.c#L121-L137>) [waylandbridge/awl_bufferqueue.c:395–417](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_bufferqueue.c#L395-L417>) |
|
||
| SC scanout / SC source selection | `tryhead` never waits; an unsignaled frame retains the previous buffer/geometry. The render-thread looper watches completion and triggers another pass. When scanout submits the buffer, its original acquire fence is already signaled, so `setBuffer` receives **`-1`**, not the client fence. [waylandbridge/awl_bufferqueue.c:420–425](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_bufferqueue.c#L420-L425>) [waylandbridge/awl_sc.cpp:472–501](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L472-L501>) [waylandbridge/awl_sc.cpp:727–740](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L727-L740>) [waylandbridge/awl_sc.cpp:847–860](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L847-L860>) |
|
||
| SC GPU-copy destination | The daemon exports the blit's native fence and passes that fence to SF as the destination AHB's acquire fence. Reusing a target waits on SF's prior release fence via `eglWaitSyncKHR` where available; fallback is CPU wait. These are the daemon-owned target's fences, distinct from the client-source fence. [waylandbridge/awl_sc.cpp:752–796](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L752-L796>) [waylandbridge/awl_gl.cpp:399–411](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_gl.cpp#L399-L411>) |
|
||
|
||
Poll treats error/hangup/invalid-fd events as completion to avoid permanent stalls; `SYNC_IOC_FILE_INFO` validates the explicit fence type but does not make these error paths successful rendering. **Inferred:** MobileGL should send valid, signaled-on-completion sync_files and propagate rendering failure separately rather than rely on error-event behavior. [waylandbridge/awl_bufferqueue.c:111–137](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_bufferqueue.c#L111-L137>) [waylandbridge/awl_bufferqueue.c:175–192](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_bufferqueue.c#L175-L192>)
|
||
|
||
### 2.2 Release fences and `wl_buffer.release`
|
||
|
||
The common rule is **last queue/consumer reference → `bq_release_cb`**. If the commit has an explicit release object, it gets `fenced_release(release_fd)` or `immediate_release` when no fence exists. Otherwise the daemon tries to import its read-completion fence into the dma-buf reservation with `DMA_BUF_IOCTL_IMPORT_SYNC_FILE`, `DMA_BUF_SYNC_READ`. A live `wl_buffer` then gets **`wl_buffer.release` in both cases**, even with explicit sync. `release` therefore need not mean the fence has already signaled. [waylandbridge/awl_bufferqueue.c:201–210](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_bufferqueue.c#L201-L210>) [waylandbridge/awl_surface.c:84–108](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_surface.c#L84-L108>) [waylandbridge/awl_esync.c:66–78](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_esync.c#L66-L78>)
|
||
|
||
| Mode | When the consumer reference is returned |
|
||
|---|---|
|
||
| EGL whole-window | After draw submission, with a native GPU-read fence; `glFinish()` if native-fence creation fails. `put` happens **before** the vsync-blocking `eglSwapBuffers`. The ring may still retain its current head, so this is not an unconditional immediate protocol release of the newest buffer. [waylandbridge/awl_renderer.cpp:382–405](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_renderer.cpp#L382-L405>) [waylandbridge/awl_bufferqueue.c:379–388](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_bufferqueue.c#L379-L388>) |
|
||
| SC `SCANOUT` | Held while SF uses it. API **36+**, if the symbol is available: `setBufferWithRelease` → per-buffer callback → `put(element,release_fence)`. Older **29–35** strategy: transaction `OnComplete` reports the **previous** buffer's release fence after replacement. [waylandbridge/awl_sc.cpp:86–97](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L86-L97>) [waylandbridge/awl_sc.cpp:329–353](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L329-L353>) |
|
||
| SC `EGL` | Client source is put with the blit's fence after copying; SF keeps a reference to Anland's separate pool slot instead. Again the ring head may defer actual protocol release. [waylandbridge/awl_sc.cpp:94–97](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L94-L97>) [waylandbridge/awl_sc.cpp:922–935](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L922-L935>) |
|
||
| shm, either renderer | Logic stores the latest shm source; backend uploads the damaged pixels. `awl_surface_shm_end(consumed=1)` sends source `wl_buffer.release` and immediate explicit release after the CPU source has been read. Failed uploads leave the source pending. [anland/include/awl.h:325–342](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/include/awl.h#L325-L342>) [waylandbridge/awl_surface.c:1201–1209](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_surface.c#L1201-L1209>) |
|
||
|
||
Without explicit sync, commit snapshots existing writer fences using `DMA_BUF_IOCTL_EXPORT_SYNC_FILE` with `DMA_BUF_SYNC_READ`; `ENOTTY` or `EINVAL` disables future export attempts and readiness falls back to polling the dma-buf itself for `POLLIN`. This assumes the producer driver records completion in the dma-buf reservation. The release-side import return value is ignored by `bq_release_cb`, so there is no implemented CPU-wait fallback if that ioctl is unsupported. **Inferred:** a split MobileGL producer should prefer explicit acquire **and** release synchronization; CPU-complete submission is a slower safe producer fallback, but reuse must still honor the consumer's release fence. [waylandbridge/awl_surface.c:199–209](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_surface.c#L199-L209>) [waylandbridge/awl_bufferqueue.c:140–159](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_bufferqueue.c#L140-L159>) [waylandbridge/awl_bufferqueue.c:184–192](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_bufferqueue.c#L184-L192>) [waylandbridge/awl_surface.c:90–102](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_surface.c#L90-L102>)
|
||
|
||
## 3. Presentation, pacing, buffering, scaling and subsurfaces
|
||
|
||
`wl_surface.frame` creates callbacks on the surface's list. `awl_surface_presented()` sends each outstanding callback `done(awl_now_ms())`; `awl_now_ms` derives from **CLOCK_MONOTONIC** and wraps into a 32-bit millisecond value. It does not deliver a hardware presentation timestamp. No `wp_presentation` global or presentation-time implementation appears in server setup/build registration. **Inferred:** frame callbacks are pacing opportunities here, not evidence that a particular frame physically scanned out. [waylandbridge/awl_surface.c:825–859](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_surface.c#L825-L859>) [waylandbridge/awl_surface.c:1221–1238](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_surface.c#L1221-L1238>) [waylandbridge/awl_internal.h:43–46](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_internal.h#L43-L46>) [waylandbridge/awl_server.c:385–401](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_server.c#L385-L401>) [waylandbridge/CMakeLists.txt:309–349](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/CMakeLists.txt#L309-L349>)
|
||
|
||
EGL uses **one render thread per window**, `eglSwapInterval(...,1)`, and sends callbacks for the layers drawn after `eglSwapBuffers` returns. SC has a shared Choreographer render loop: callbacks go out on the **vsync tick** for visible layers that have a buffer; commits can trigger one off-tick latch opportunity per window/interval, and fence completion can retry it. Off-tick passes do not send frame callbacks. The comments document that sending callbacks from SF `OnComplete` introduced an extra vsync and reduced a paced client to **29 fps**. [waylandbridge/awl_renderer.cpp:417–439](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_renderer.cpp#L417-L439>) [waylandbridge/awl_sc.cpp:46–75](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L46-L75>) [waylandbridge/awl_sc.cpp:431–440](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L431-L440>) [waylandbridge/awl_sc.cpp:982–984](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L982-L984>) [waylandbridge/awl_sc.cpp:1105–1145](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L1105-L1145>)
|
||
|
||
**How many buffers:** there is no protocol requirement to use exactly two or three. The queue holds **8** and the AHB cache holds **8**. SC's own copy-target pool is **4** because three slots skipped alternate frames in the documented SF pipeline. SC comments describe up to three client buffers held by SF plus the newest queue head as a fourth, and Mesa mailbox commonly having four. **Inferred recommendation:** start a dma-buf/AHB swapchain with **four reusable buffers**, pace normal GUI rendering by callbacks, and handle release/fence backpressure; allow more buffers if device testing requires them. A one-buffer renderer cannot assume the current head will be released without replacement. Do not interpret an eight-slot queue as eight-buffer minimum. [waylandbridge/awl_bufferqueue.c:43–48](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_bufferqueue.c#L43-L48>) [waylandbridge/awl_ahb.hpp:53–63](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.hpp#L53-L63>) [waylandbridge/awl_sc.cpp:224–235](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L224-L235>) [waylandbridge/awl_sc.cpp:389–400](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L389-L400>) [waylandbridge/awl_bufferqueue.c:379–388](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_bufferqueue.c#L379-L388>)
|
||
|
||
A client repeatedly running ahead of vsync switches from SC scanout to GPU-copy mode after **15** consecutive ticks with dropped/superseded frames, and returns after **120** quiet ticks. The comments call these roughly ¼ s / 2 s, but the code thresholds are ticks, so their duration depends on refresh rate. The stated experiment is **vkmark 123 fps scanned out versus ~1300 fps copying**; those are source-comment measurements of producer throughput, not 1300 screen refreshes or a portable benchmark result. [waylandbridge/awl_sc.cpp:389–400](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L389-L400>) [waylandbridge/awl_sc.cpp:871–884](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L871-L884>)
|
||
|
||
**Parking:** detaching/pausing an Android host window marks it unattached and tears down its renderer/SC tree. New dirty notifications become no-ops and do not send `frame_done`. Commit-time queue draining is disabled for detached roots, intentionally withholding buffers so ordinary clients park on swap/release/callback waits. Cursor queues are an explicit exception and still drain. **Inferred:** this is cooperative backpressure, not SIGSTOP or a guarantee that an app ignoring callbacks and continually allocating new buffers uses zero CPU; queue-full frames are returned immediately. [waylandbridge/waylandbridge.cpp:328–333](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/waylandbridge.cpp#L328-L333>) [waylandbridge/waylandbridge.cpp:1118–1122](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/waylandbridge.cpp#L1118-L1122>) [waylandbridge/awl_surface.c:231–249](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_surface.c#L231-L249>) [waylandbridge/awl_surface.c:211–215](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_surface.c#L211-L215>)
|
||
|
||
**Scaling:** actual globals are **`wp_viewporter` v1** and **`wp_fractional_scale_manager_v1` v1** (some comments inaccurately use a `zwp_` prefix). Source/destination state is double buffered; output scale stays 1; preferred scale is quantized in **1/120** units as `(zoom_pct*120+50)/100`, sent on object creation and on zoom changes. Viewport destination determines logical size when set. MobileGL WSI must distinguish surface logical size from pixel-buffer dimensions. The last sentence is **inferred** from these transformations. [waylandbridge/awl_viewport.c:1–17](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_viewport.c#L1-L17>) [waylandbridge/awl_viewport.c:53–63](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_viewport.c#L53-L63>) [waylandbridge/awl_viewport.c:352–369](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_viewport.c#L352-L369>) [waylandbridge/awl_viewport.c:416–456](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_viewport.c#L416-L456>)
|
||
|
||
**Subsurfaces:** `wl_subcompositor` v1 supports synchronized and desynchronized children, parent-applied position/stacking, ancestor-recursive effective sync, and cascade application of latched state. Each child has its own buffer queue; SC maps layers to siblings, EGL composites the traversal. The public collection limit is **`AWL_MAX_LAYERS=16`**; the renderer separately includes a cursor slot. **Inferred:** whole-desktop nested compositors and clients with many layers should be tested against this finite layer collection, and a MobileGL integration must preserve per-surface rather than only per-window buffer/fence state. [waylandbridge/awl_subsurface.c:10–35](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_subsurface.c#L10-L35>) [waylandbridge/awl_subsurface.c:396–417](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_subsurface.c#L396-L417>) [waylandbridge/awl_subsurface.c:494–506](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_subsurface.c#L494-L506>) [anland/include/awl.h:369–388](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/include/awl.h#L369-L388>) [waylandbridge/awl_renderer.cpp:284–288](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_renderer.cpp#L284-L288>)
|
||
|
||
## 4. Connection and process model, including another Android daemon
|
||
|
||
### 4.1 Container connection and identities
|
||
|
||
The actual default is **`/data/local/tmp/awl/wayland-0`**. Config keys `runtime_dir` and `socket_listen` choose another directory or disable the pathname listener. `socket_listen` defaults true; the daemon makes the runtime directory mode **0777**, binds an `AF_UNIX/SOCK_STREAM` listener with backlog **8**, and chmods the socket **0666**. This contradicts the README table's blanket “No socket file” statement; that statement describes Binder-only operation, not the default code path. [waylandbridge/waylandbridge.cpp:1175–1199](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/waylandbridge.cpp#L1175-L1199>) [waylandbridge/waylandbridge.cpp:2085–2105](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/waylandbridge.cpp#L2085-L2105>) [waylandbridge/waylandbridge.cpp:2126–2143](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/waylandbridge.cpp#L2126-L2143>) [anland/README.md:31–38](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/README.md#L31-L38>)
|
||
|
||
Droidspaces is expected to bind **`/data/local/tmp/awl:/run/anland`** into the container. This checkout documents/assumes that preconfiguration; `anland-session/setup.sh` does not create the Android/container bind mount. Setup runs as the non-root desktop user and installs the user service and patched Xwayland. The session sets `XDG_RUNTIME_DIR=/run/user/$(id -u)` if absent, links **`$XDG_RUNTIME_DIR/wayland-anland` → `/run/anland/wayland-0`**, and exports **`WAYLAND_DISPLAY=wayland-anland`**. It launches rootless Xwayland, obtains the display number with `-displayfd`, runs miniwm, and publishes environment through `~/.anlandx-env` and `systemctl --user set-environment`. [shell/src/main/java/com/anland/shell/ds/DsCli.java:31–44](<https://github.com/SuperTurtleDev/anland-shell/blob/920fcfc8159690f5232e2d9c7c3294d4c1481145/src/main/java/com/anland/shell/ds/DsCli.java#L31-L44>) [anland/anland-session/setup.sh:1–13](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/anland-session/setup.sh#L1-L13>) [anland/anland-session/setup.sh:61–64](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/anland-session/setup.sh#L61-L64>) [anland/anland-session/anland-session.sh:26–45](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/anland-session/anland-session.sh#L26-L45>) [anland/anland-session/anland-session.sh:108–120](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/anland-session/anland-session.sh#L108-L120>) [anland/anland-session/anland-session.sh:146–184](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/anland-session/anland-session.sh#L146-L184>)
|
||
|
||
`service.sh` is the module's late-start service: it labels `waylandbridge` **`u:object_r:awl_daemon_exec:s0`** and starts it directly with `nohup`. Policy transitions **`ksu + awl_daemon_exec → awl_daemon`**, and explicitly marks **`awl_daemon` permissive**. There is no UID drop in this launch/main path. **Inferred:** in the intended root-manager launch, the daemon remains **UID 0**, SELinux domain **`u:r:awl_daemon:s0`**; the executable label is a different SELinux object type. Do not generalize this to launches through an unconfigured root manager/domain. [anland/module/service.sh:1–26](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/service.sh#L1-L26>) [anland/module/sepolicy.rule:14–26](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/sepolicy.rule#L14-L26>) [waylandbridge/waylandbridge.cpp:2110–2124](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/waylandbridge.cpp#L2110-L2124>)
|
||
|
||
Container apps run as the selected **Linux desktop account**, not a universal fixed UID: anland-shell defaults to the first non-root account, probes passwd for the UID, then uses `su - <user>` and `systemd-run --user`; explicit root launches use a different direct path. Anland's policy comments identify container Chrome as **`droidspacesd`**, and rules grant that domain socket/fd access. **Inferred:** this is the expected Android SELinux domain for the documented Droidspaces deployment; exact host UID mapping and domain for another chroot/PRoot/LXC setup must be measured because Droidspaces implementation/user-namespace configuration is not included here. [shell/src/main/java/com/anland/shell/ds/DsCli.java:318–339](<https://github.com/SuperTurtleDev/anland-shell/blob/920fcfc8159690f5232e2d9c7c3294d4c1481145/src/main/java/com/anland/shell/ds/DsCli.java#L318-L339>) [shell/src/main/java/com/anland/shell/ds/DsCli.java:374–392](<https://github.com/SuperTurtleDev/anland-shell/blob/920fcfc8159690f5232e2d9c7c3294d4c1481145/src/main/java/com/anland/shell/ds/DsCli.java#L374-L392>) [shell/src/main/java/com/anland/shell/ds/DsCli.java:435–458](<https://github.com/SuperTurtleDev/anland-shell/blob/920fcfc8159690f5232e2d9c7c3294d4c1481145/src/main/java/com/anland/shell/ds/DsCli.java#L435-L458>) [anland/module/sepolicy.rule:76–87](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/sepolicy.rule#L76-L87>) [anland/module/sepolicy.rule:142–154](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/sepolicy.rule#L142-L154>)
|
||
|
||
The Binder name is **`anland.host`**, interface **`anland.IHost`**, service label **`u:object_r:anland_host_service:s0`**. `customize.sh` copies the device's live platform service contexts and appends the supplied mapping. Third-party app domains `untrusted_app_29` and `untrusted_app` are allowed to find the service. Socket pathname access is deliberately narrower: `awl_runtime_sock` is created by a type transition and container `droidspacesd` gets socket-file access and `connectto`; APKs are intended to use Binder connection injection. World-writable DAC permissions alone are insufficient. [anland/module/plat_service_contexts.anland:1](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/plat_service_contexts.anland#L1>) [anland/module/customize.sh:13–26](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/customize.sh#L13-L26>) [anland/module/sepolicy.rule:4–7](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/sepolicy.rule#L4-L7>) [anland/module/sepolicy.rule:76–92](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/sepolicy.rule#L76-L92>) [waylandbridge/waylandbridge.cpp:2153–2177](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/waylandbridge.cpp#L2153-L2177>)
|
||
|
||
### 4.2 Binder fd injection and libawl
|
||
|
||
`Awl.getWaylandFd()` delegates to `AwlClient.connect()`, which creates **the socketpair in the app**, sends one end through Binder **`T_CONNECT=18`**, closes its local duplicate of the sent end, and keeps the other for `wl_display_connect_to_fd`. Creating the pair in the app preserves its `SO_PEERCRED` UID/PID for ownership checks. The exact Java parcel body is **`writeInt(1); writeInt(0); writeFileDescriptor(theirs)`**, after the interface token. Use that implementation as the authority: nearby daemon comments/log text contain inconsistent abbreviated descriptions of the ParcelFileDescriptor wire. [libawl/Awl.java:69–78](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/app/libawl/src/main/java/com/anlandnext/awl/Awl.java#L69-L78>) [libawl/AwlClient.java:335–381](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/app/libawl/src/main/java/com/anlandnext/awl/AwlClient.java#L335-L381>) [anland/include/awl.h:140–150](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/include/awl.h#L140-L150>) [waylandbridge/waylandbridge.cpp:1820–1847](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/waylandbridge.cpp#L1820-L1847>)
|
||
|
||
The Binder handler passes the fd to `awl_server_add_client`; a pipe marshals the integer fd to the Wayland event thread, which calls `wl_client_create`. Binder is used to establish the connection; subsequent Wayland messages and buffer/fence fd passing use that socket. [waylandbridge/awl_server.c:308–347](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_server.c#L308-L347>) [waylandbridge/waylandbridge.cpp:1837–1847](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/waylandbridge.cpp#L1837-L1847>)
|
||
|
||
`Awl.java` exposes connection, window listing/events, `attachWindow`, and native client spawning. `spawnClient` inherits the connection as **`WAYLAND_SOCKET=<fd>`** through fork/exec. `attachWindow` hosts a Wayland window in an Activity; `AwlClient.surface` sends window id, dimensions, Android `Surface`, death token and host identity through **`T_SURFACE=1`**. The daemon compares the Binder caller UID with the Wayland client's UID for non-allowlisted hosts; root/self/host APK have privileged scope. [libawl/Awl.java:25–41](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/app/libawl/src/main/java/com/anlandnext/awl/Awl.java#L25-L41>) [libawl/Awl.java:188–227](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/app/libawl/src/main/java/com/anlandnext/awl/Awl.java#L188-L227>) [libawl/Awl.java:279–294](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/app/libawl/src/main/java/com/anlandnext/awl/Awl.java#L279-L294>) [libawl/AwlClient.java:28–40](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/app/libawl/src/main/java/com/anlandnext/awl/AwlClient.java#L28-L40>) [libawl/AwlClient.java:80–95](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/app/libawl/src/main/java/com/anlandnext/awl/AwlClient.java#L80-L95>) [waylandbridge/waylandbridge.cpp:1528–1567](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/waylandbridge.cpp#L1528-L1567>)
|
||
|
||
`include/awl.h` is the daemon's **logic-layer C API**, despite its header comment saying v2 while **`AWL_ABI_VERSION=3`**. It provides `awl_server_start/add_client`, window callbacks, per-surface queue access and shm access. It is not an Android client AHB-submission library; the Android AAR and this server-internal API serve different roles. [anland/include/awl.h:1–25](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/include/awl.h#L1-L25>) [anland/include/awl.h:132–150](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/include/awl.h#L132-L150>) [anland/include/awl.h:309–342](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/include/awl.h#L309-L342>)
|
||
|
||
**Could an Android GL server use libawl? — inferred:** yes, as a Wayland client/host under its own identity, or by implementing the same Binder connection protocol natively. It still needs Wayland WSI and one of Anland's accepted buffer types. An unprivileged server APK cannot use `attachWindow` to claim arbitrary existing container-UID windows. For split rendering while the Linux application owns the Wayland connection, keep that ownership and associate imported buffers with that client's resources through a new controlled native-buffer import/broker interface. `libawl` alone does not create this association. [libawl/Awl.java:69–81](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/app/libawl/src/main/java/com/anlandnext/awl/Awl.java#L69-L81>) [libawl/Awl.java:279–294](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/app/libawl/src/main/java/com/anlandnext/awl/Awl.java#L279-L294>) [waylandbridge/waylandbridge.cpp:1528–1567](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/waylandbridge.cpp#L1528-L1567>) [waylandbridge/awl_internal.h:71–81](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_internal.h#L71-L81>)
|
||
|
||
### 4.3 Launching a second Android-side daemon and required access
|
||
|
||
**Inferred: feasible using the same deployment pattern.** A bionic MobileGL render-server ELF can be launched by a root-module service and expose, for example, **`/data/local/tmp/awl/mobilegl.sock`**, seen as **`/run/anland/mobilegl.sock`** in the existing bind mount. Anland already demonstrates a second Android native service: PulseAudio is launched from the same module, in `awl_daemon` but under the host APK UID because Android audio policy requires a package-associated UID. That audio-specific UID rule is not evidence that GLES requires an APK UID. [anland/module/service.sh:29–42](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/service.sh#L29-L42>) [anland/module/service.sh:119–138](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/service.sh#L119-L138>) [anland/module/service.sh:153–170](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/service.sh#L153-L170>) [shell/src/main/java/com/anland/shell/ds/DsCli.java:31–35](<https://github.com/SuperTurtleDev/anland-shell/blob/920fcfc8159690f5232e2d9c7c3294d4c1481145/src/main/java/com/anland/shell/ds/DsCli.java#L31-L35>)
|
||
|
||
The following are **inferred policy requirements**, mapped to working Anland rules rather than claimed as a tested complete policy for every vendor:
|
||
|
||
| Direction / resource | Existing evidence and implication for MobileGL |
|
||
|---|---|
|
||
| Container connects to render server | Need runtime-directory traversal, socket-file read/write/open permissions, and `droidspacesd → mobilegl_daemon:unix_stream_socket connectto`; mirror the existing runtime socket labeling/allow rules. Reusing `awl_daemon` and its runtime socket type is the smallest deployment experiment; a separate domain/type is the maintainable change. [anland/module/sepolicy.rule:76–102](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/sepolicy.rule#L76-L102>) |
|
||
| Cross-domain fd passing | Grant **both relevant directions of `fd use`**, e.g. `mobilegl_daemon ↔ droidspacesd` and `mobilegl_daemon ↔ awl_daemon`, plus communication and underlying file/device access. Anland has explicit `droidspacesd ↔ awl_daemon` grants. Shared memory/dma-buf/fence access is more than pathname connectivity. [anland/module/sepolicy.rule:142–146](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/sepolicy.rule#L142-L146>) [anland/module/sepolicy.rule:111–120](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/sepolicy.rule#L111-L120>) |
|
||
| APK-based GL server | Anland's grants for `untrusted_app[_29] ↔ awl_daemon` do not automatically authorize `untrusted_app ↔ droidspacesd`. Either add appropriate direct socket/fd permissions for the new relation, or use a trusted Android broker to pass a socketpair through Binder. Binder service labeling/find, `call transfer`, `fd use`, and socket read/write rights are separate requirements. [anland/module/sepolicy.rule:4–7](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/sepolicy.rule#L4-L7>) [anland/module/sepolicy.rule:39–51](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/sepolicy.rule#L39-L51>) [anland/module/sepolicy.rule:76–87](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/sepolicy.rule#L76-L87>) |
|
||
| Native server's Android graphics access | Mirror GPU node, dma-buf heap, vendor library, allocator/mapper service access; root DAC does not replace SELinux/service-manager policy. The audited domain is permissive, so its allow list is not proof of completeness in enforcing mode. [anland/module/sepolicy.rule:18](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/sepolicy.rule#L18>) [anland/module/sepolicy.rule:111–125](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/sepolicy.rule#L111-L125>) [anland/module/sepolicy.rule:159–161](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/sepolicy.rule#L159-L161>) |
|
||
| Imported native buffers reach SF/HWC | Consumers may need `fd use` for the domain that originally opened/allocated the fd, not merely the relay daemon. Existing rules explicitly grant `surfaceflinger`, `system_server`, and `hal_graphics_composer_default` access to `awl_daemon` fds. For a new allocation domain, audit/add that new origin's grants too. [anland/module/sepolicy.rule:126–141](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/sepolicy.rule#L126-L141>) |
|
||
|
||
**Inferred transport limit:** local Unix fd passing is a natural fit. TCP cannot transmit a kernel fd/AHB handle as a usable remote kernel object; TCP rendering needs a local allocation broker and pixel/data transfer, or another explicitly implemented transport, before the final local Wayland buffer submission. Anland's relevant existing paths all use local fd passing or local shm, not TCP buffer ingress. [waylandbridge/waylandbridge.cpp:2085–2105](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/waylandbridge.cpp#L2085-L2105>) [libawl/AwlClient.java:342–365](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/app/libawl/src/main/java/com/anlandnext/awl/AwlClient.java#L342-L365>) [waylandbridge/awl_ahb.cpp:444–464](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L444-L464>) [waylandbridge/awl_bufferqueue.h:63–76](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_bufferqueue.h#L63-L76>)
|
||
|
||
## 5. GPU acceleration supplied today and Xwayland requirements
|
||
|
||
### 5.1 What each project actually configures
|
||
|
||
| Project / environment | Observed rendering stack |
|
||
|---|---|
|
||
| Main 6.x container session | Defaults **`MESA_LOADER_DRIVER_OVERRIDE=kgsl`**, **`GALLIUM_DRIVER=kgsl`**, **`FD_FORCE_KGSL=1`**. Dependency setup installs an external lfdevs Mesa tarball containing EGL/GLX/GBM/Gallium/`kgsl_dri.so` and Turnip Vulkan. These are container-side Mesa drivers; waylandbridge's Android EGL is separate. [anland/anland-session/anland-session.sh:108–112](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/anland-session/anland-session.sh#L108-L112>) [anland/anland-session/deps_noble.sh:104–113](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/anland-session/deps_noble.sh#L104-L113>) [anland/anland-session/deps_noble.sh:130–141](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/anland-session/deps_noble.sh#L130-L141>) |
|
||
| anland-shell | Root/Droidspaces app launcher, not a renderer. It supplies the same KGSL defaults and starts the selected user's app in the container session. [shell/src/main/java/com/anland/shell/ds/DsCli.java:31–44](<https://github.com/SuperTurtleDev/anland-shell/blob/920fcfc8159690f5232e2d9c7c3294d4c1481145/src/main/java/com/anland/shell/ds/DsCli.java#L31-L44>) [shell/src/main/java/com/anland/shell/ds/DsCli.java:59–68](<https://github.com/SuperTurtleDev/anland-shell/blob/920fcfc8159690f5232e2d9c7c3294d4c1481145/src/main/java/com/anland/shell/ds/DsCli.java#L59-L68>) [shell/src/main/java/com/anland/shell/ds/DsCli.java:374–382](<https://github.com/SuperTurtleDev/anland-shell/blob/920fcfc8159690f5232e2d9c7c3294d4c1481145/src/main/java/com/anland/shell/ds/DsCli.java#L374-L382>) |
|
||
| lfdevs Anland: Termux | Explicitly legacy-based; supports Termux native and PRoot/Chroot/LXC. Qualcomm acceleration uses **Freedreno OpenGL and Turnip Vulkan**. Native installation guide currently points to **26.3.0-devel-20260824**, except Weston to **26.2.0-devel-20260709-weston**; container guide points to mesa-for-android-container. Image package URLs pin the 26.3 snapshot. [Termux/README.md:7–13](<https://github.com/lfdevs/anland-termux/blob/a70879f059a2e8439fdb132195c3dd10d4810106/README.md#L7-L13>) [Termux/docs/user-guide.md:148–152](<https://github.com/lfdevs/anland-termux/blob/a70879f059a2e8439fdb132195c3dd10d4810106/docs/user-guide.md#L148-L152>) [Termux/images/packages.json:1–16](<https://github.com/lfdevs/anland-termux/blob/a70879f059a2e8439fdb132195c3dd10d4810106/images/packages.json#L1-L16>) |
|
||
| Termux Mesa build at that release tag | Package version **26.3.0**, Mesa commit **`98f3d6229d61452cef80f8563af7c56ae599dc14`**. `-Dgbm=enabled -Dopengl=true -Degl=enabled -Dgles2=enabled -Dglx=dri -Dllvm=enabled -Dplatforms=x11,wayland -Dglvnd=enabled`; Gallium **llvmpipe,softpipe,virgl,zink**, plus **freedreno** on ARM/aarch64; Vulkan **swrast**, plus **freedreno**; **`-Dfreedreno-kmds=msm,kgsl`**. [termux-packages/mesa/build.sh:6–35](https://github.com/lfdevs/termux-packages/blob/ccc9cc550efc604188242285f99884183596ebb0/packages/mesa/build.sh#L6-L35) [termux-packages/mesa/build.sh:177–185](https://github.com/lfdevs/termux-packages/blob/ccc9cc550efc604188242285f99884183596ebb0/packages/mesa/build.sh#L177-L185) |
|
||
| Container Mesa workflow at the same Mesa commit | `-Dplatforms=x11,wayland`, Gallium **freedreno,zink,virgl,llvmpipe**, Vulkan **freedreno**, EGL/GLES2/GLVND enabled, GLX DRI, **`-Dfreedreno-kmds=kgsl`**. These are build settings in the release-tag tree, not proof every installed package/device selects every built driver. [mesa-for-android-container/build-check.yml:57–81](https://github.com/lfdevs/mesa-for-android-container/blob/98f3d6229d61452cef80f8563af7c56ae599dc14/.github/workflows/build-check.yml#L57-L81) |
|
||
| asveroid Plasma installer | Explicitly **Termux Native**, no root, Snapdragon/Adreno. Installs patched KWin/Xwayland and Freedreno; script still pins **26.2.0-devel-20260709** Mesa and `mesa-vulkan-icd-freedreno`, older than lfdevs' current guide. [Plasma/README.md:3–23](<https://github.com/asveroid/anland-plasma-termux/blob/099710d413b47d2f3f8c5091a95ee2732d3be0e6/README.md#L3-L23>) [Plasma/install-anland-plasma.sh:26–31](<https://github.com/asveroid/anland-plasma-termux/blob/099710d413b47d2f3f8c5091a95ee2732d3be0e6/install-anland-plasma.sh#L26-L31>) |
|
||
|
||
**Zink:** it is built in both Mesa configurations above, but neither main 6.x's defaults nor Termux's documented KGSL overrides establish it as the default path. Termux's manual examples use `GALLIUM_DRIVER=freedreno`, `TURNIP_KMD=kgsl`, `FD_FORCE_KGSL=1` and `XWAYLAND_FORCE_KGSL_SURFACELESS=1`; the native example also uses `ANLAND_NO_DRM_DEVICE=1 EGL_PLATFORM=surfaceless`. Do not conflate this legacy Termux surfaceless integration with the four-hunk main 6.x Xwayland patch. [termux-packages/mesa/build.sh:177–185](https://github.com/lfdevs/termux-packages/blob/ccc9cc550efc604188242285f99884183596ebb0/packages/mesa/build.sh#L177-L185) [mesa-for-android-container/build-check.yml:65–80](https://github.com/lfdevs/mesa-for-android-container/blob/98f3d6229d61452cef80f8563af7c56ae599dc14/.github/workflows/build-check.yml#L65-L80) [Termux/docs/user-guide.md:251–262](<https://github.com/lfdevs/anland-termux/blob/a70879f059a2e8439fdb132195c3dd10d4810106/docs/user-guide.md#L251-L262>) [Termux/docs/user-guide.md:294–300](<https://github.com/lfdevs/anland-termux/blob/a70879f059a2e8439fdb132195c3dd10d4810106/docs/user-guide.md#L294-L300>) [anland/patches/xwayland/anland-kgsl-glamor.patch:1–109](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/patches/xwayland/anland-kgsl-glamor.patch#L1-L109>)
|
||
|
||
**Native vs containers:** Termux-native uses Android/Termux packages; container images install distro-appropriate Mesa into `/usr`. PRoot-Distro examples use `--shared-tmp`; the general guide bind-mounts Termux `$TMPDIR` to container `/tmp`, so the legacy daemon socket is shared. Official GitHub Termux APK variants use shared UID; the compatible variant instead holds the socket in Termux and transfers its fd over Binder. These are legacy transport arrangements, not the 6.x `/run/anland/wayland-0` setup. [Termux/README.md:31–34](<https://github.com/lfdevs/anland-termux/blob/a70879f059a2e8439fdb132195c3dd10d4810106/README.md#L31-L34>) [Termux/docs/user-guide.md:60–96](<https://github.com/lfdevs/anland-termux/blob/a70879f059a2e8439fdb132195c3dd10d4810106/docs/user-guide.md#L60-L96>) [Termux/docs/user-guide.md:199–206](<https://github.com/lfdevs/anland-termux/blob/a70879f059a2e8439fdb132195c3dd10d4810106/docs/user-guide.md#L199-L206>) [Termux/images/debian-plasma.Dockerfile:55–58](<https://github.com/lfdevs/anland-termux/blob/a70879f059a2e8439fdb132195c3dd10d4810106/images/debian-plasma.Dockerfile#L55-L58>) [Termux/docs/user-guide.md:294–300](<https://github.com/lfdevs/anland-termux/blob/a70879f059a2e8439fdb132195c3dd10d4810106/docs/user-guide.md#L294-L300>)
|
||
|
||
**Non-Adreno GPUs:** lfdevs says MediaTek Dimensity, Google Tensor and Samsung Exynos currently use **LLVMpipe**, may fail to enter the desktop, and only **Tensor G1** had been personally tested successfully in PRoot/Chroot. The Plasma installer repeats the software-rendering limitation. This is not a verified hardware-accelerated Mali, PowerVR or Xclipse support statement. No specific accelerated PowerVR/Xclipse result or desktop GL-version claim was established in the reviewed docs/builds. **Inferred:** MobileGL may remove the Mesa KGSL dependency for rendering, but current 6.x's snapalloc-dependent buffer import is a separate obstacle on other vendors. [Termux/README.md:25–29](<https://github.com/lfdevs/anland-termux/blob/a70879f059a2e8439fdb132195c3dd10d4810106/README.md#L25-L29>) [Plasma/README.md:59](<https://github.com/asveroid/anland-plasma-termux/blob/099710d413b47d2f3f8c5091a95ee2732d3be0e6/README.md#L59>) [termux-packages/mesa/build.sh:177–185](https://github.com/lfdevs/termux-packages/blob/ccc9cc550efc604188242285f99884183596ebb0/packages/mesa/build.sh#L177-L185) [waylandbridge/awl_ahb.cpp:139–146](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L139-L146>) [waylandbridge/awl_ahb.cpp:264–274](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L264-L274>)
|
||
|
||
**GL versions and performance:** the evidence establishes Freedreno FD650 direct acceleration in a device issue, and waylandbridge requests an **OpenGL ES 3 context**; neither establishes that graphical Linux apps universally get desktop GL 4.6 or any other specific maximum. No `glxinfo`/`eglinfo` version result was found in the cited compatibility docs or device report. The concrete performance figures available in the current code are the **29 fps** callback-placement regression and **123 vs ~1300 fps** vkmark scanout/copy comparison, with the measurement limitations described in §3. [anland issue #84](https://github.com/SuperTurtleDev/anland/issues/84) [waylandbridge/awl_gl.cpp:102–105](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_gl.cpp#L102-L105>) [Termux/README.md:25–29](<https://github.com/lfdevs/anland-termux/blob/a70879f059a2e8439fdb132195c3dd10d4810106/README.md#L25-L29>) [waylandbridge/awl_sc.cpp:60–75](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L60-L75>) [waylandbridge/awl_sc.cpp:389–400](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L389-L400>)
|
||
|
||
### 5.2 What Xwayland glamor needs, and what the patch changes
|
||
|
||
The vendored source is Xwayland **24.1.10**. The patch README explicitly says the display GPU is reached via KGSL and that the chosen fallback `/dev/dri/renderD128` is redirected by the patched Mesa stack. It does not demonstrate that a stock distro GBM can open a working DRM render node on every phone. [anland/patches/xwayland/README.anland.md:1–9](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/patches/xwayland/README.anland.md#L1-L9>) [anland/patches/xwayland/README.anland.md:29–39](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/patches/xwayland/README.anland.md#L29-L39>)
|
||
|
||
| Requirement / interface | Actual pinned GBM implementation |
|
||
|---|---|
|
||
| GBM device and EGL platform | Opens/uses a device fd, calls `gbm_create_device`, gets `EGL_PLATFORM_GBM_MESA`, and initializes EGL. It tries desktop GL then GLES, requires a renderer and `GL_OES_EGL_image`, and rejects named llvmpipe/softpipe glamor renderers. [xserver/hw/xwayland/xwayland-glamor-gbm.c:1710–1766](https://gitlab.freedesktop.org/xorg/xserver/-/blob/5a873951579f1ff894f71489f3651a55d6dde250/hw/xwayland/xwayland-glamor-gbm.c#L1710-1766) |
|
||
| dma-buf image import | Tests both dma-buf import and modifiers extension support for `dmabuf_capable`; constructs `EGL_LINUX_DMA_BUF_EXT` images with plane fds, offsets, pitches and modifier words. **Inferred:** a replacement provider for this path needs compatible GBM allocation/import and EGL image behavior, not only GL draw entry points. [xserver/hw/xwayland/xwayland-glamor-gbm.c:243–277](https://gitlab.freedesktop.org/xorg/xserver/-/blob/5a873951579f1ff894f71489f3651a55d6dde250/hw/xwayland/xwayland-glamor-gbm.c#L243-277) [xserver/hw/xwayland/xwayland-glamor-gbm.c:1769–1773](https://gitlab.freedesktop.org/xorg/xserver/-/blob/5a873951579f1ff894f71489f3651a55d6dde250/hw/xwayland/xwayland-glamor-gbm.c#L1769-1773) |
|
||
| dma-buf export | The pinned GBM path obtains fds through **`gbm_bo_get_fd_for_plane` / `gbm_bo_get_fd`**. It does **not** require/call `EGL_MESA_image_dma_buf_export` in this file. That extension can be useful for an EGL-owned-image export design, but calling it a universal glamor prerequisite would overstate this implementation. [xserver/hw/xwayland/xwayland-glamor-gbm.c:486–533](https://gitlab.freedesktop.org/xorg/xserver/-/blob/5a873951579f1ff894f71489f3651a55d6dde250/hw/xwayland/xwayland-glamor-gbm.c#L486-533) [xserver/hw/xwayland/xwayland-glamor-gbm.c:844–881](https://gitlab.freedesktop.org/xorg/xserver/-/blob/5a873951579f1ff894f71489f3651a55d6dde250/hw/xwayland/xwayland-glamor-gbm.c#L844-881) |
|
||
| DRI3 | Registers `dri3_screen_init` and import/export callbacks for pixmaps/fds. The patch fixes a modifier problem specifically in imported DRI3 buffers. **Inferred:** accelerated X11 clients need a compatible GLX/DRI3/GBM integration (or another deliberate X11 route); a MobileGL Wayland EGL swap implementation alone does not transparently replace that client/server contract. [xserver/hw/xwayland/xwayland-glamor-gbm.c:1812–1826](https://gitlab.freedesktop.org/xorg/xserver/-/blob/5a873951579f1ff894f71489f3651a55d6dde250/hw/xwayland/xwayland-glamor-gbm.c#L1812-1826) [anland/patches/xwayland/anland-kgsl-glamor.patch:22–37](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/patches/xwayland/anland-kgsl-glamor.patch#L22-L37>) |
|
||
|
||
The four patch changes are precise:
|
||
|
||
1. Submit **`DRM_FORMAT_MOD_INVALID`** via linux-dmabuf without requiring it to be found in the advertised modifier set. [anland/patches/xwayland/anland-kgsl-glamor.patch:3–21](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/patches/xwayland/anland-kgsl-glamor.patch#L3-L21>)
|
||
2. Rewrite bogus modifier **`1274ULL` (`0x4FA`) → DRM_FORMAT_MOD_LINEAR`** before GBM import, for the documented Mesa/KGSL DRI3 bug. This is not general tiled-buffer conversion. [anland/patches/xwayland/anland-kgsl-glamor.patch:22–37](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/patches/xwayland/anland-kgsl-glamor.patch#L22-L37>)
|
||
3. Wait for default feedback only when protocol version is **≥4**; initialize `main_dev=NULL`; when unavailable or without a render node, use **`XWAYLAND_GBM_DEVICE`**, default **`/dev/dri/renderD128`**. [anland/patches/xwayland/anland-kgsl-glamor.patch:38–91](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/patches/xwayland/anland-kgsl-glamor.patch#L38-L91>)
|
||
4. Permit glamor when **linux-dmabuf v3** exists despite no `wl_drm` or v4 feedback. [anland/patches/xwayland/anland-kgsl-glamor.patch:92–109](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/patches/xwayland/anland-kgsl-glamor.patch#L92-L109>)
|
||
|
||
**Inferred:** these changes solve device selection and buffer-routing assumptions in that Mesa-based stack. They do not implement a GBM backend for MobileGL, import full AHB handles into Anland, add AB24/UBWC support, or make container glibc load Android vendor GLES directly. [anland/patches/xwayland/anland-kgsl-glamor.patch:1–109](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/patches/xwayland/anland-kgsl-glamor.patch#L1-L109>) [waylandbridge/awl_dmabuf.c:17–22](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_dmabuf.c#L17-L22>) [waylandbridge/awl_ahb.cpp:334–340](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L334-L340>)
|
||
|
||
## 6. waylandbridge's own renderer and Android driver loading
|
||
|
||
The build uses the Android NDK toolchain, **arm64-v8a**, platform **android-35**. Wayland/ffi are static dependencies, and Anland's protocol/adapter source is compiled into one executable. The graphics/system dependencies remain **`binder_ndk android log EGL GLESv3 nativewindow`**; there is no evidence here of a fully static libc+vendor-GLES binary. The README's “single statically-linked ELF” should be read in light of the executable's actual link configuration. [anland/Makefile:77–83](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/Makefile#L77-L83>) [waylandbridge/CMakeLists.txt:225–244](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/CMakeLists.txt#L225-L244>) [waylandbridge/CMakeLists.txt:303–308](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/CMakeLists.txt#L303-L308>) [waylandbridge/CMakeLists.txt:364–365](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/CMakeLists.txt#L364-L365>) [anland/README.md:73–78](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/README.md#L73-L78>)
|
||
|
||
The renderer calls ordinary Android EGL entry points: `eglGetDisplay(EGL_DEFAULT_DISPLAY)`, `eglInitialize`, `eglChooseConfig` for ES3 and window/pbuffer use, and `eglCreateContext(...CLIENT_VERSION,3)`. It resolves EGLImage/native-buffer/fence procedures with `eglGetProcAddress`. Root executable startup and policy explicitly provide GPU/vendor-file access. **Inferred:** this is a bionic Android-native consumer of the platform EGL/GLES dispatch stack and device graphics implementation, not container Mesa doing the daemon's composition. [waylandbridge/awl_gl.cpp:34–106](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_gl.cpp#L34-L106>) [anland/module/service.sh:20–26](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/service.sh#L20-L26>) [anland/module/sepolicy.rule:111–120](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/sepolicy.rule#L111-L120>)
|
||
|
||
There is no custom graphics linker namespace creation or `android_dlopen_ext` bypass in these renderer files. The explicit `dlopen` shown in `waylandbridge.cpp` loads **`libbinder_ndk.so`** to resolve platform-only service-manager/thread-pool functions, not a vendor GLES driver. **Inferred:** a root bionic executable can follow this platform-EGL route without being an APK; root is not itself a linker-namespace bypass. This source does not prove that arbitrary vendor DSOs can be dlopened directly from arbitrary namespaces, nor that a glibc executable can load them. [waylandbridge/waylandbridge.cpp:100–119](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/waylandbridge.cpp#L100-L119>) [waylandbridge/awl_gl.cpp:34–76](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_gl.cpp#L34-L76>) [waylandbridge/CMakeLists.txt:364–365](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/CMakeLists.txt#L364-L365>)
|
||
|
||
The target does not link Vulkan or call it in these rendering paths. **Inferred:** Anland provides concrete precedent for MobileGL's bionic GLES/Magma server deployment; an Espryt/Vulkan server using Android's Vulkan loader is a separate validation task. Linker/loader policy, extension support and buffer interoperability for that Vulkan path cannot be certified from Anland's GLES implementation. [waylandbridge/CMakeLists.txt:350–365](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/CMakeLists.txt#L350-L365>) [waylandbridge/awl_gl.cpp:34–106](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_gl.cpp#L34-L106>)
|
||
|
||
## 7. What the derivatives reveal about other frame paths
|
||
|
||
**E7G wlroots-anland.** This is a wlroots **0.20.x** native backend for the **E7G private Anland protocol**, not a backend for 6.x linux-dmabuf Wayland ingress. It connects to `ANLAND_SOCKET` (default `/tmp/display_daemon.sock`) and imports a **consumer-owned pool**. Its allocator gets the selected pool fd/info, wraps a one-plane `wlr_dmabuf_attributes` with offset/stride/modifier, and advertises `WLR_BUFFER_CAP_DMABUF`. Commit locks the submitted buffer until consumer-ready, then sends a wlroots presentation event and a new frame opportunity. **Inferred:** this demonstrates an alternative allocation direction useful for MobileGL—Android supplies render targets—but does not supply native-AHB ingress to current waylandbridge. Its `VSYNC|ZERO_COPY` presentation flags are backend claims based on consumer-ready, not proof of a physical scanout timestamp. [wlroots/README.anland.md:3–19](<https://github.com/E7G/wlroots-anland/blob/351399132de0b208ddb36d0ea2fa74cbe668fb72/README.anland.md#L3-L19>) [wlroots/backend/anland/allocator.c:33–58](<https://github.com/E7G/wlroots-anland/blob/351399132de0b208ddb36d0ea2fa74cbe668fb72/backend/anland/allocator.c#L33-L58>) [wlroots/backend/anland/allocator.c:64–76](<https://github.com/E7G/wlroots-anland/blob/351399132de0b208ddb36d0ea2fa74cbe668fb72/backend/anland/allocator.c#L64-L76>) [wlroots/backend/anland/output.c:21–34](<https://github.com/E7G/wlroots-anland/blob/351399132de0b208ddb36d0ea2fa74cbe668fb72/backend/anland/output.c#L21-L34>) [wlroots/backend/anland/output.c:67–76](<https://github.com/E7G/wlroots-anland/blob/351399132de0b208ddb36d0ea2fa74cbe668fb72/backend/anland/output.c#L67-L76>)
|
||
|
||
**Yizhou147 anland-drm.** This replaces the legacy Android APK consumer with a DRM/KMS consumer. The implemented main display allocation uses **DRM dumb buffers**, exports PRIME fds, sends a pool with format **1 (RGBA8888)**, modifier **0**, offset **0**, selects a producer render target, then page-flips it. Although the README lists dma-heap/ion helpers, those are not the allocation calls used by this main display path. Its README says untested, but the newer progress note reports a binary running on **houji/Snapdragon 8 Gen 3**, detecting a **5120×2560@60** connector/input, while `drmModeSetCrtc` still fails **Permission denied**, even after stopping SF and trying root. **Inferred:** it demonstrates the protocol's independence from Android windowing, not a working universal replacement for HWC. Its loop closes the returned render fence before page-flip without waiting/passing it onward, so it is also not a reliable synchronization precedent. [anland-drm/consumer/drm_display.c:146–196](<https://github.com/Yizhou147/anland-drm/blob/850f7ca0e0f25d34dd04baa7e12e8751bcff4951/consumer/drm_display.c#L146-L196>) [anland-drm/consumer/drm_consumer.c:242](<https://github.com/Yizhou147/anland-drm/blob/850f7ca0e0f25d34dd04baa7e12e8751bcff4951/consumer/drm_consumer.c#L242>) [anland-drm/consumer/drm_consumer.c:275–320](<https://github.com/Yizhou147/anland-drm/blob/850f7ca0e0f25d34dd04baa7e12e8751bcff4951/consumer/drm_consumer.c#L275-L320>) [anland-drm/README.md:3–13](<https://github.com/Yizhou147/anland-drm/blob/850f7ca0e0f25d34dd04baa7e12e8751bcff4951/README.md#L3-L13>) [anland-drm/PROGRESS.md:14–34](<https://github.com/Yizhou147/anland-drm/blob/850f7ca0e0f25d34dd04baa7e12e8751bcff4951/PROGRESS.md#L14-L34>)
|
||
|
||
**Legacy 5.x “Anland Display Protocol.”** `common/protocol.h` defines packed control/data messages (`CONSUMER_HELLO=1`, `PRODUCER_HELLO=2`, `SCREEN_INFO=7`, `PICKUP_FDS=9`, `FDS_READY=10`; data `BUF_READY=100`, `REFRESH_DONE=101`, `BUFS_READY=200`; `MAX_BUFS=8`) and `buf_info {uint32_t stride,width,height,format; uint64_t modifier; uint32_t offset;}`. Android consumer dequeues **real ANativeWindow buffers**, retains the original `ANativeWindowBuffer*`, exports only native-handle **fd[0]** plus descriptor, and sets modifier/offset **0**. It waits on dequeue fences before selecting a producer target; producer completion returns a sync_file that is passed to `queueBuffer` for SF to wait on. There is no need to forge a return-path AHB because the Android consumer kept the original native buffer. **Inferred:** this is a strong pattern for a native-handle extension or Android-owned target pool, but the existing private protocol itself does **not** transmit a complete arbitrary native_handle/AHB; compressed storage cannot safely be represented just by claiming modifier 0. [legacy/common/protocol.h:7–49](<https://github.com/SuperTurtleDev/anland/blob/9ab13eb146bc9f3dd3cc44cabc268659d9eb0a46/common/protocol.h#L7-L49>) [legacy/consumers/anland_v5/android_consumer/app/src/main/jni/native_consumer.c:133–188](<https://github.com/SuperTurtleDev/anland/blob/9ab13eb146bc9f3dd3cc44cabc268659d9eb0a46/consumers/anland_v5/android_consumer/app/src/main/jni/native_consumer.c#L133-L188>) [legacy/consumers/anland_v5/android_consumer/app/src/main/jni/native_consumer.c:778–813](<https://github.com/SuperTurtleDev/anland/blob/9ab13eb146bc9f3dd3cc44cabc268659d9eb0a46/consumers/anland_v5/android_consumer/app/src/main/jni/native_consumer.c#L778-L813>) [legacy/consumers/anland_v5/android_consumer/app/src/main/jni/native_consumer.c:953–1003](<https://github.com/SuperTurtleDev/anland/blob/9ab13eb146bc9f3dd3cc44cabc268659d9eb0a46/consumers/anland_v5/android_consumer/app/src/main/jni/native_consumer.c#L953-L1003>)
|
||
|
||
## 8. Concrete changes for MobileGL AHB output and avoiding the forge
|
||
|
||
This section is **inferred design**, not existing Anland functionality. The starting constraint is that MobileGL allocates genuine Android AHBs, commonly **`AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM`**, with DRM identity **ABGR8888/AB24** for little-endian RGBA bytes. Current Anland admits AR24/XR24 and then overwrites the storage description with BGRA donor metadata. In contrast, Anland's **own SC copy pool already allocates RGBA AHBs** with `GPU_COLOR_OUTPUT | GPU_SAMPLED_IMAGE | COMPOSER_OVERLAY` and imports/displays them. Thus the output side is already capable of consuming suitable genuine RGBA AHBs; ingress, representation and lifetime are the missing pieces. [drm-uapi/drm_fourcc.h:193–199](https://github.com/lfdevs/mesa-for-android-container/blob/98f3d6229d61452cef80f8563af7c56ae599dc14/include/drm-uapi/drm_fourcc.h#L193-L199) [waylandbridge/awl_dmabuf.c:17–22](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_dmabuf.c#L17-L22>) [waylandbridge/awl_ahb.cpp:334–336](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L334-L336>) [waylandbridge/awl_sc.cpp:279–300](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L279-L300>)
|
||
|
||
### 8.1 Smallest paths, and exactly what each buys
|
||
|
||
| Path | Changes and limits — all inferred |
|
||
|---|---|
|
||
| **No Anland change, functional baseline** | MobileGL finishes/readbacks or otherwise converts to packed BGRA/XRGB in `wl_shm`, and its client-side Wayland WSI commits it. This avoids forge/vendor metadata dependence but pays readback/transfer/upload and does not preserve compressed zero-copy buffers. Anland's shm upload/release path already exists. [waylandbridge/awl_gl.cpp:331–379](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_gl.cpp#L331-L379>) [anland/include/awl.h:325–342](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/include/awl.h#L325-L342>) |
|
||
| **No Anland change, narrow dma-buf experiment** | Produce actual linear, zero-offset AR24/XR24 storage, send modifier **0**, correct byte pitch and sync_files. Requires a device where the snapalloc calibration/import works; allocating an RGBA/UBWC AHB and sending fd[0] is not this path. There is no generic portability guarantee. [waylandbridge/awl_dmabuf.c:17–22](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_dmabuf.c#L17-L22>) [waylandbridge/awl_ahb.cpp:139–146](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L139-L146>) [waylandbridge/awl_ahb.cpp:264–274](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L264-L274>) [waylandbridge/awl_ahb.cpp:334–395](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L334-L395>) |
|
||
| **Smallest meaningful native-AHB change** | Add a native-AHB registration/import side channel and a way to create/associate a Wayland `wl_buffer` with the registered object. Keep the existing renderers/SC transactions, but resolve registered buffers directly to retained AHBs instead of `awl_ahb_wrap`. Add correct RGBA/AB24 format handling and propagate lifetime/fences. This avoids donor allocation/calibration/patching and the fabricated local socketpair round-trip. [waylandbridge/awl_internal.h:71–81](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_internal.h#L71-L81>) [waylandbridge/awl_surface.c:184–218](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_surface.c#L184-L218>) [waylandbridge/awl_ahb.cpp:534–569](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L534-L569>) [waylandbridge/awl_gl.cpp:257–289](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_gl.cpp#L257-L289>) [waylandbridge/awl_sc.cpp:727–743](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L727-L743>) |
|
||
| **Clean native buffer path** | Versioned Wayland extension or authenticated broker protocol, typed buffer payload, resource-owned native import and stable generation/identity; preserve linux-dmabuf as a separate raw-layout importer. Full AHB metadata stays on Android; the glibc client carries an opaque resource/token and fences. This makes native compressed layouts opaque to Anland's logical layer and leaves import interpretation to gralloc/EGL/SF. [waylandbridge/awl_bufferqueue.h:5–8](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_bufferqueue.h#L5-L8>) [waylandbridge/awl_bufferqueue.h:63–76](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_bufferqueue.h#L63-L76>) [anland/include/awl.h:309–323](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/include/awl.h#L309-L323>) [waylandbridge/awl_gl.cpp:257–289](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_gl.cpp#L257-L289>) |
|
||
|
||
Adding only AB24 to `k_supported` is **insufficient**: `awl_ahb_wrap` still forces HAL BGRA, the cache does not include format, and no original native metadata is available. Extending the forge to another HAL format could help a narrowly compatible linear layout but would still retain the vendor-layout dependency and would not preserve UBWC. [waylandbridge/awl_dmabuf.c:17–22](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_dmabuf.c#L17-L22>) [waylandbridge/awl_ahb.cpp:334–336](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L334-L336>) [waylandbridge/awl_ahb.cpp:546–568](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L546-L568>)
|
||
|
||
### 8.2 Concrete insertion points
|
||
|
||
| Function / file | Small viable edit → clean design direction — all inferred |
|
||
|---|---|
|
||
| `awl_dmabuf_setup`, `params_*`, `dmabuf_buffer_create` in `awl_dmabuf.c`; `awl_server_start`; protocol generation in `CMakeLists.txt` | Add a distinct native-buffer factory/registration protocol and register it at startup; do not overload linux-dmabuf plane fds with arbitrary gralloc metadata. For the existing raw path, fix INVALID and explicitly validate supported modifier, zero offset, format, dimensions and extent instead of discarding layout information. [waylandbridge/awl_dmabuf.c:49–85](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_dmabuf.c#L49-L85>) [waylandbridge/awl_dmabuf.c:105–175](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_dmabuf.c#L105-L175>) [waylandbridge/awl_server.c:385–401](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_server.c#L385-L401>) [waylandbridge/CMakeLists.txt:309–349](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/CMakeLists.txt#L309-L349>) [waylandbridge/awl_internal.h:35–40](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_internal.h#L35-L40>) |
|
||
| `host_on_transact` / Binder transaction enum in `waylandbridge.cpp`, if choosing an Android broker | Add a **new** registration operation for complete AHB handle/descriptor import, returning a scoped token. Reuse Binder only as transport/identity infrastructure: `T_CONNECT` currently transfers a Wayland socket. Bind a token to the right client/resource or an explicit delegated registration capability, accounting for the different container and Android-server UIDs. [waylandbridge/waylandbridge.cpp:184–196](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/waylandbridge.cpp#L184-L196>) [waylandbridge/waylandbridge.cpp:1528–1567](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/waylandbridge.cpp#L1528-L1567>) [waylandbridge/waylandbridge.cpp:1820–1847](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/waylandbridge.cpp#L1820-L1847>) |
|
||
| `struct awl_buffer` / destruction in `awl_internal.h`, `awl_surface.c`, `awl_dmabuf.c` | Add payload kind and opaque native import reference, with acquire/release ownership, descriptor and stable identity. Keep the imported AHB alive after `wl_buffer.destroy` while queue/SF references exist, following the existing wrapper lifetime pattern. [waylandbridge/awl_internal.h:65–81](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_internal.h#L65-L81>) [waylandbridge/awl_dmabuf.c:33–46](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_dmabuf.c#L33-L46>) [waylandbridge/awl_surface.c:58–67](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_surface.c#L58-L67>) |
|
||
| `awl_surface_apply_buffer` and `struct awl_bq_buffer` | Carry an opaque native-buffer reference/token with each frame; preserve acquire/release fences and format/geometry. The current queue treats **`dmabuf_fd<0` as NULL/unmap**, so merely adding an AHB pointer while leaving fd=-1 silently breaks readiness/render selection. Introduce a tagged payload or retain a real backing fd in the narrow implementation; update readiness, close/unref, and all fd-based branches. [waylandbridge/awl_surface.c:184–218](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_surface.c#L184-L218>) [waylandbridge/awl_bufferqueue.h:63–76](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_bufferqueue.h#L63-L76>) [waylandbridge/awl_bufferqueue.c:184–210](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_bufferqueue.c#L184-L210>) [waylandbridge/awl_sc.cpp:896–898](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L896-L898>) |
|
||
| `awl_ahb_cache_get` / `awl_ahb_wrap` | Resolve native registrations directly to an acquired AHB, bypassing the forge. An inode-only association can be a controlled prototype, but the clean key is an imported-buffer identity/generation plus complete descriptor; include format and distinguish native handles from reconstructed raw buffers. Multiple metadata handles or reuse must not collide. Cache the real AHB/EGLImage per swapchain buffer. [waylandbridge/awl_ahb.cpp:534–569](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L534-L569>) [waylandbridge/awl_ahb.hpp:53–86](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.hpp#L53-L86>) |
|
||
| `awl_gl_tex_import`, `render_frame` in `awl_renderer.cpp` | `awl_gl_tex_import` already takes any suitable AHB through native-buffer EGL import. Feed it the real AHB; extend source selection and format/opacity handling for AB24/XB24. Keep shm's BGRA byte uploader separate; do not apply an unnecessary R/B swap to native RGBA. [waylandbridge/awl_gl.cpp:257–289](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_gl.cpp#L257-L289>) [waylandbridge/awl_gl.cpp:331–345](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_gl.cpp#L331-L345>) [waylandbridge/awl_renderer.cpp:292–334](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_renderer.cpp#L292-L334>) |
|
||
| `sc_render_window`, `latch_scanout`, `latch_egl` in `awl_sc.cpp`; `awl_ahb_hwc_scanout_ok` | The pitch oracle is specifically for forged linear BGRA and must not decide native opaque/compressed AHB eligibility. Submit a real allocation with its original metadata; require suitable AHB usage and let Android import/composition determine support. Retain a real-AHB-to-real-AHB GPU-copy mode for pacing or unsupported direct composition where source sampling succeeds. [waylandbridge/awl_ahb.cpp:60–91](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L60-L91>) [waylandbridge/awl_sc.cpp:279–300](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L279-L300>) [waylandbridge/awl_sc.cpp:727–796](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L727-L796>) [waylandbridge/awl_sc.cpp:903–935](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L903-L935>) |
|
||
| `awl_esync.c`, queue readiness/release, SC release callbacks | Reuse sync_file per-commit semantics. Minimal implementation can keep current ready-before-latch behavior. A later SC optimization can pass the producer fence directly to SF instead of waiting for readiness, but requires redesigning mailbox selection, ownership and fence lifetime; it is not a one-line replacement of `-1`. Native payloads without a raw dma-buf need explicit release, not the current implicit-reservation fallback. [waylandbridge/awl_esync.c:121–170](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_esync.c#L121-L170>) [waylandbridge/awl_bufferqueue.c:184–192](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_bufferqueue.c#L184-L192>) [waylandbridge/awl_surface.c:84–108](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_surface.c#L84-L108>) [waylandbridge/awl_sc.cpp:329–353](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L329-L353>) [waylandbridge/awl_sc.cpp:727–740](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L727-L740>) |
|
||
| `module/service.sh`, `module/sepolicy.rule`, service contexts; container mount/session configuration | Launch the bionic server and expose the local socket/broker, with domain-specific communication, allocator/GPU and fd-origin consumer permissions as in §4. Keep normal Wayland surface ownership tied to the Linux app unless explicitly choosing an APK-owned client architecture. [anland/module/service.sh:20–26](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/service.sh#L20-L26>) [anland/module/sepolicy.rule:76–87](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/sepolicy.rule#L76-L87>) [anland/module/sepolicy.rule:111–161](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/sepolicy.rule#L111-L161>) [waylandbridge/waylandbridge.cpp:1528–1567](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/waylandbridge.cpp#L1528-L1567>) |
|
||
|
||
### 8.3 Native handle transport, UBWC and the remaining MobileGL responsibilities
|
||
|
||
**Inferred native transport design:** use **`AHardwareBuffer_sendHandleToUnixSocket` → `AHardwareBuffer_recvHandleFromUnixSocket`** on a **dedicated local Unix channel** between the two bionic processes, or design a Binder HardwareBuffer/native-handle transport. The two Unix APIs are documented for `AF_UNIX` and available since **API 26**. Preserve **all** handle fds and integer metadata, original descriptor/usage and allocation identity; do not copy the forge's hardcoded two-fd/13-word reconstruction as a universal format. Associate the imported object with a Wayland `wl_buffer` by a scoped token/protocol object. Do not interleave AHB's byte stream into the ordinary Wayland socket without a defined protocol envelope. A real interprocess AHB receive/import remains, but the fabricated local donor round-trip and its calibration are eliminated. [android/hardware_buffer.h:528–549](https://android.googlesource.com/platform/frameworks/native/+/refs/heads/main/libs/nativewindow/include/android/hardware_buffer.h#528) [waylandbridge/awl_ahb.cpp:139–146](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L139-L146>) [waylandbridge/awl_ahb.cpp:398–464](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L398-L464>) [waylandbridge/awl_internal.h:65–81](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_internal.h#L65-L81>) [waylandbridge/waylandbridge.cpp:1820–1847](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/waylandbridge.cpp#L1820-L1847>)
|
||
|
||
For SC presentation, allocate with the intended usage from the start. Android's header specifically says **`AHARDWAREBUFFER_USAGE_COMPOSER_OVERLAY`** is needed for `ASurfaceTransaction_setBuffer` when the buffer was allocated directly with `AHardwareBuffer_allocate`; the framework normally adds it for framework-managed buffers. **Inferred:** MobileGL's native target pool should use the render/sample/composer combination already used by `pool_create`, subject to device support, rather than changing usage words after allocation. [android/hardware_buffer.h:270–290](https://android.googlesource.com/platform/frameworks/native/+/refs/heads/main/libs/nativewindow/include/android/hardware_buffer.h#270) [waylandbridge/awl_sc.cpp:284–300](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L284-L300>)
|
||
|
||
**Inferred UBWC policy:** allow only genuine native allocations that the consuming Android stack can import/sample/present with their original metadata. The extension should carry them opaquely, not assert a linear DRM modifier or patch a donor blob. Unsupported native import should fail clearly before claiming the buffer usable; an optional GPU blit requires the native source to be importable first. RGBA support and compressed-layout support are related but distinct. Anland's own RGBA target pool demonstrates the right allocation/import pattern, not proof of every vendor's compression support. [waylandbridge/awl_sc.cpp:279–300](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L279-L300>) [waylandbridge/awl_gl.cpp:257–285](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_gl.cpp#L257-L285>) [waylandbridge/awl_ahb.cpp:334–395](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L334-L395>)
|
||
|
||
**Inferred MobileGL work items:** client-side Wayland EGL/GL window-system integration must create/resize buffers, attach/damage/commit the correct `wl_surface`, obey configure/viewport geometry, pace frames, and retain each buffer until release plus fence completion. Android-side rendering must allocate/import the target, export a real completion sync_file, and honor consumer release before reuse. The Anland changes above solve buffer handoff, not missing GL entry points or X11 GLX/DRI3/GBM integration. A staged validation should first prove `wl_shm`, then native uncompressed RGBA AHB import, then fence/lifetime/resize/parking correctness, and only then vendor compression and direct-SC behavior. These stages are recommendations grounded in the existing independent paths, not tests performed in this audit. [waylandbridge/awl_surface.c:184–218](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_surface.c#L184-L218>) [waylandbridge/awl_surface.c:825–859](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_surface.c#L825-L859>) [waylandbridge/awl_viewport.c:1–17](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_viewport.c#L1-L17>) [waylandbridge/awl_esync.c:121–200](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_esync.c#L121-L200>) [waylandbridge/awl_sc.cpp:279–300](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L279-L300>) [waylandbridge/awl_sc.cpp:727–796](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L727-L796>) [xserver/hw/xwayland/xwayland-glamor-gbm.c:1710–1773](https://gitlab.freedesktop.org/xorg/xserver/-/blob/5a873951579f1ff894f71489f3651a55d6dde250/hw/xwayland/xwayland-glamor-gbm.c#L1710-1773) [xserver/hw/xwayland/xwayland-glamor-gbm.c:1812–1826](https://gitlab.freedesktop.org/xorg/xserver/-/blob/5a873951579f1ff894f71489f3651a55d6dde250/hw/xwayland/xwayland-glamor-gbm.c#L1812-1826)
|
||
|
||
**Preferred integration, inferred:** keep Linux applications as ordinary Wayland clients, keep MobileGL's render server bionic, and add a small native-buffer bridge into Anland's existing AHB-consuming renderers. This addresses both RGBA/opaque gralloc layouts and the donor-forge dependency without making the glibc client understand vendor gralloc internals. The exact viable compressed formats, enforced SELinux policy and release-depth behavior remain device-validation questions. [waylandbridge/awl_gl.cpp:257–289](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_gl.cpp#L257-L289>) [waylandbridge/awl_sc.cpp:279–300](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L279-L300>) [waylandbridge/awl_sc.cpp:727–743](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_sc.cpp#L727-L743>) [waylandbridge/awl_ahb.cpp:139–146](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/services/waylandbridge/awl_ahb.cpp#L139-L146>) [anland/module/sepolicy.rule:18](<https://github.com/SuperTurtleDev/anland/blob/cc1691805fe6aca6851b6fcccb6a1e33019026c1/module/sepolicy.rule#L18>)
|