Files
MobileGL/docs/Disaggregated/notes/anland/report-anland.md
T

117 KiB
Raw Blame History

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 Termux/README.md:7–13

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 waylandbridge/awl_internal.h:65–81 waylandbridge/awl_gl.cpp:257–289 waylandbridge/awl_sc.cpp:727–743

The highest-impact findings are:

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
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 libwayland/wayland-shm.c:451–475 waylandbridge/awl_surface.c:1155–1160
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
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 waylandbridge/awl_dmabuf.c:17–22 waylandbridge/awl_dmabuf.c:54–57
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 waylandbridge/awl_dmabuf.c:217–229 waylandbridge/awl_internal.h:35–40
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
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 anland/patches/xwayland/README.anland.md:29–39

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 drm-uapi/drm_fourcc.h:527–544 waylandbridge/awl_internal.h:35–40 waylandbridge/awl_dmabuf.c:49–85

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 waylandbridge/awl_dmabuf.c:105–175
  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 waylandbridge/awl_dmabuf.c:33–46 waylandbridge/awl_bufferqueue.h:63–76
  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 waylandbridge/awl_bufferqueue.c:201–210 waylandbridge/awl_bufferqueue.c:379–388
  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 waylandbridge/awl_ahb.cpp:534–569
  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 waylandbridge/awl_gl.cpp:257–289 waylandbridge/awl_renderer.cpp:382–419
  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 waylandbridge/awl_sc.cpp:358–364 waylandbridge/awl_sc.cpp:727–743 waylandbridge/awl_sc.cpp:903–975

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 waylandbridge/awl_ahb.cpp:139–146

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 waylandbridge/awl_ahb.cpp:172–220 waylandbridge/awl_ahb.cpp:223–274

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 waylandbridge/awl_ahb.cpp:300–320 waylandbridge/awl_ahb.cpp:325–395

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

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 waylandbridge/awl_ahb.cpp:334–336 drm-uapi/drm_fourcc.h:193–199
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 waylandbridge/awl_internal.h:71–81 waylandbridge/awl_bufferqueue.h:63–76
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 waylandbridge/awl_dmabuf.c:130–175 waylandbridge/awl_ahb.cpp:377–395
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 waylandbridge/awl_ahb.cpp:377–395
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
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 waylandbridge/awl_sc.cpp:903–935
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 waylandbridge/awl_ahb.cpp:264–274 waylandbridge/awl_ahb.cpp:337–340 waylandbridge/awl_renderer.cpp:295–323 waylandbridge/awl_sc.cpp:729–735

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 waylandbridge/awl_ahb.cpp:422–464 waylandbridge/awl_ahb.cpp:562–569

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 waylandbridge/awl_dmabuf.c:49–85 waylandbridge/awl_bufferqueue.h:63–76 waylandbridge/awl_ahb.cpp:334–395 waylandbridge/awl_sc.cpp:922–930

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 waylandbridge/waylandbridge.cpp:140–197 libawl/AwlClient.java:80–95 libawl/AwlClient.java:335–381 waylandbridge/awl_ahb.cpp:444–464

External evidence, not merged behavior: draft PR #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 anland PR #92 anland PR #92

Android service access can also fail more severely than a returned import error: closed issue #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 anland/module/sepolicy.rule:159–161

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 waylandbridge/awl_esync.c:121–170 waylandbridge/awl_esync.c:179–200 waylandbridge/awl_esync.c:265–277 waylandbridge/awl_bufferqueue.c:175–179

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 waylandbridge/CMakeLists.txt:309–349 waylandbridge/protocols/linux-explicit-synchronization-unstable-v1.xml:39 xserver/hw/xwayland/xwayland-glamor-gbm.c:1788–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 waylandbridge/awl_bufferqueue.c:121–137 waylandbridge/awl_bufferqueue.c:395–417
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 waylandbridge/awl_sc.cpp:472–501 waylandbridge/awl_sc.cpp:727–740 waylandbridge/awl_sc.cpp:847–860
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 waylandbridge/awl_gl.cpp:399–411

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 waylandbridge/awl_bufferqueue.c:175–192

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 waylandbridge/awl_surface.c:84–108 waylandbridge/awl_esync.c:66–78

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 waylandbridge/awl_bufferqueue.c:379–388
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 waylandbridge/awl_sc.cpp:329–353
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 waylandbridge/awl_sc.cpp:922–935
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 waylandbridge/awl_surface.c:1201–1209

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 waylandbridge/awl_bufferqueue.c:140–159 waylandbridge/awl_bufferqueue.c:184–192 waylandbridge/awl_surface.c:90–102

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 waylandbridge/awl_surface.c:1221–1238 waylandbridge/awl_internal.h:43–46 waylandbridge/awl_server.c:385–401 waylandbridge/CMakeLists.txt:309–349

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 waylandbridge/awl_sc.cpp:46–75 waylandbridge/awl_sc.cpp:431–440 waylandbridge/awl_sc.cpp:982–984 waylandbridge/awl_sc.cpp:1105–1145

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 waylandbridge/awl_ahb.hpp:53–63 waylandbridge/awl_sc.cpp:224–235 waylandbridge/awl_sc.cpp:389–400 waylandbridge/awl_bufferqueue.c:379–388

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 waylandbridge/awl_sc.cpp:871–884

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 waylandbridge/waylandbridge.cpp:1118–1122 waylandbridge/awl_surface.c:231–249 waylandbridge/awl_surface.c:211–215

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 waylandbridge/awl_viewport.c:53–63 waylandbridge/awl_viewport.c:352–369 waylandbridge/awl_viewport.c:416–456

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 waylandbridge/awl_subsurface.c:396–417 waylandbridge/awl_subsurface.c:494–506 anland/include/awl.h:369–388 waylandbridge/awl_renderer.cpp:284–288

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 waylandbridge/waylandbridge.cpp:2085–2105 waylandbridge/waylandbridge.cpp:2126–2143 anland/README.md:31–38

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 anland/anland-session/setup.sh:1–13 anland/anland-session/setup.sh:61–64 anland/anland-session/anland-session.sh:26–45 anland/anland-session/anland-session.sh:108–120 anland/anland-session/anland-session.sh:146–184

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 anland/module/sepolicy.rule:14–26 waylandbridge/waylandbridge.cpp:2110–2124

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 shell/src/main/java/com/anland/shell/ds/DsCli.java:374–392 shell/src/main/java/com/anland/shell/ds/DsCli.java:435–458 anland/module/sepolicy.rule:76–87 anland/module/sepolicy.rule:142–154

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 anland/module/customize.sh:13–26 anland/module/sepolicy.rule:4–7 anland/module/sepolicy.rule:76–92 waylandbridge/waylandbridge.cpp:2153–2177

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 libawl/AwlClient.java:335–381 anland/include/awl.h:140–150 waylandbridge/waylandbridge.cpp:1820–1847

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 waylandbridge/waylandbridge.cpp:1837–1847

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 libawl/Awl.java:188–227 libawl/Awl.java:279–294 libawl/AwlClient.java:28–40 libawl/AwlClient.java:80–95 waylandbridge/waylandbridge.cpp:1528–1567

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 anland/include/awl.h:132–150 anland/include/awl.h:309–342

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 libawl/Awl.java:279–294 waylandbridge/waylandbridge.cpp:1528–1567 waylandbridge/awl_internal.h:71–81

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 anland/module/service.sh:119–138 anland/module/service.sh:153–170 shell/src/main/java/com/anland/shell/ds/DsCli.java:31–35

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
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 anland/module/sepolicy.rule:111–120
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 anland/module/sepolicy.rule:39–51 anland/module/sepolicy.rule:76–87
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 anland/module/sepolicy.rule:111–125 anland/module/sepolicy.rule:159–161
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

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 libawl/AwlClient.java:342–365 waylandbridge/awl_ahb.cpp:444–464 waylandbridge/awl_bufferqueue.h:63–76

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 anland/anland-session/deps_noble.sh:104–113 anland/anland-session/deps_noble.sh:130–141
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 shell/src/main/java/com/anland/shell/ds/DsCli.java:59–68 shell/src/main/java/com/anland/shell/ds/DsCli.java:374–382
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 Termux/docs/user-guide.md:148–152 Termux/images/packages.json:1–16
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 termux-packages/mesa/build.sh:177–185
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
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 Plasma/install-anland-plasma.sh:26–31

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 mesa-for-android-container/build-check.yml:65–80 Termux/docs/user-guide.md:251–262 Termux/docs/user-guide.md:294–300 anland/patches/xwayland/anland-kgsl-glamor.patch:1–109

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 Termux/docs/user-guide.md:60–96 Termux/docs/user-guide.md:199–206 Termux/images/debian-plasma.Dockerfile:55–58 Termux/docs/user-guide.md:294–300

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 Plasma/README.md:59 termux-packages/mesa/build.sh:177–185 waylandbridge/awl_ahb.cpp:139–146 waylandbridge/awl_ahb.cpp:264–274

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 waylandbridge/awl_gl.cpp:102–105 Termux/README.md:25–29 waylandbridge/awl_sc.cpp:60–75 waylandbridge/awl_sc.cpp:389–400

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 anland/patches/xwayland/README.anland.md:29–39

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
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 xserver/hw/xwayland/xwayland-glamor-gbm.c:1769–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 xserver/hw/xwayland/xwayland-glamor-gbm.c:844–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 anland/patches/xwayland/anland-kgsl-glamor.patch:22–37

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
  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
  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
  4. Permit glamor when linux-dmabuf v3 exists despite no wl_drm or v4 feedback. anland/patches/xwayland/anland-kgsl-glamor.patch:92–109

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 waylandbridge/awl_dmabuf.c:17–22 waylandbridge/awl_ahb.cpp:334–340

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 waylandbridge/CMakeLists.txt:225–244 waylandbridge/CMakeLists.txt:303–308 waylandbridge/CMakeLists.txt:364–365 anland/README.md:73–78

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 anland/module/service.sh:20–26 anland/module/sepolicy.rule:111–120

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 waylandbridge/awl_gl.cpp:34–76 waylandbridge/CMakeLists.txt:364–365

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 waylandbridge/awl_gl.cpp:34–106

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 wlroots/backend/anland/allocator.c:33–58 wlroots/backend/anland/allocator.c:64–76 wlroots/backend/anland/output.c:21–34 wlroots/backend/anland/output.c:67–76

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 anland-drm/consumer/drm_consumer.c:242 anland-drm/consumer/drm_consumer.c:275–320 anland-drm/README.md:3–13 anland-drm/PROGRESS.md:14–34

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 legacy/consumers/anland_v5/android_consumer/app/src/main/jni/native_consumer.c:133–188 legacy/consumers/anland_v5/android_consumer/app/src/main/jni/native_consumer.c:778–813 legacy/consumers/anland_v5/android_consumer/app/src/main/jni/native_consumer.c:953–1003

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 waylandbridge/awl_dmabuf.c:17–22 waylandbridge/awl_ahb.cpp:334–336 waylandbridge/awl_sc.cpp:279–300

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 anland/include/awl.h:325–342
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 waylandbridge/awl_ahb.cpp:139–146 waylandbridge/awl_ahb.cpp:264–274 waylandbridge/awl_ahb.cpp:334–395
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 waylandbridge/awl_surface.c:184–218 waylandbridge/awl_ahb.cpp:534–569 waylandbridge/awl_gl.cpp:257–289 waylandbridge/awl_sc.cpp:727–743
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 waylandbridge/awl_bufferqueue.h:63–76 anland/include/awl.h:309–323 waylandbridge/awl_gl.cpp:257–289

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 waylandbridge/awl_ahb.cpp:334–336 waylandbridge/awl_ahb.cpp:546–568

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 waylandbridge/awl_dmabuf.c:105–175 waylandbridge/awl_server.c:385–401 waylandbridge/CMakeLists.txt:309–349 waylandbridge/awl_internal.h:35–40
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 waylandbridge/waylandbridge.cpp:1528–1567 waylandbridge/waylandbridge.cpp:1820–1847
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 waylandbridge/awl_dmabuf.c:33–46 waylandbridge/awl_surface.c:58–67
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 waylandbridge/awl_bufferqueue.h:63–76 waylandbridge/awl_bufferqueue.c:184–210 waylandbridge/awl_sc.cpp:896–898
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 waylandbridge/awl_ahb.hpp:53–86
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 waylandbridge/awl_gl.cpp:331–345 waylandbridge/awl_renderer.cpp:292–334
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 waylandbridge/awl_sc.cpp:279–300 waylandbridge/awl_sc.cpp:727–796 waylandbridge/awl_sc.cpp:903–935
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 waylandbridge/awl_bufferqueue.c:184–192 waylandbridge/awl_surface.c:84–108 waylandbridge/awl_sc.cpp:329–353 waylandbridge/awl_sc.cpp:727–740
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 anland/module/sepolicy.rule:76–87 anland/module/sepolicy.rule:111–161 waylandbridge/waylandbridge.cpp:1528–1567

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 waylandbridge/awl_ahb.cpp:139–146 waylandbridge/awl_ahb.cpp:398–464 waylandbridge/awl_internal.h:65–81 waylandbridge/waylandbridge.cpp:1820–1847

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 waylandbridge/awl_sc.cpp:284–300

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 waylandbridge/awl_gl.cpp:257–285 waylandbridge/awl_ahb.cpp:334–395

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 waylandbridge/awl_surface.c:825–859 waylandbridge/awl_viewport.c:1–17 waylandbridge/awl_esync.c:121–200 waylandbridge/awl_sc.cpp:279–300 waylandbridge/awl_sc.cpp:727–796 xserver/hw/xwayland/xwayland-glamor-gbm.c:1710–1773 xserver/hw/xwayland/xwayland-glamor-gbm.c:1812–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 waylandbridge/awl_sc.cpp:279–300 waylandbridge/awl_sc.cpp:727–743 waylandbridge/awl_ahb.cpp:139–146 anland/module/sepolicy.rule:18