Skip to content

Ariadne browser video: in the viewport, a read-back ladder, and the box says why there's no picture (untested Android guesses) - #1429

Merged
transfix merged 1 commit into
masterfrom
fix/ariadne-browser-video-android
Nov 21, 2026
Merged

transfix merged 1 commit into
masterfrom
fix/ariadne-browser-video-android

Conversation

@transfix

Copy link
Copy Markdown
Owner

Joe's Android phone shows nicotina's feed videos as a blank box on cyberpcangel.com (arigl-web 4.0.2). Desktop Chromium plays them, and so does its Android emulation. The file isn't the problem: H.264 Main 3.1, moov first, and CORS and range requests are fine.

These are untested guesses for Android. There is no device to try them on (no USB debugging right now), so nothing here has run on a phone. Each change is meant to help if it is the cause and do nothing otherwise. If the video still doesn't show, the box now says why, so the phone can tell us without DevTools.

The browser player (src/cvc/ariadne/media_browser.cpp)

  • The hidden <video> is in the viewport. It used to sit at left: -10000px. Now it is in the top-left corner: 2 px, z-index: -1 under the canvas, opacity 0.01, pointer-events: none, aria-hidden. A phone's browser may not start or decode a video far outside the viewport (iOS Safari refuses muted autoplay there).

  • Frames are read back through a ladder:

    1. the 2D canvas kept in memory (willReadFrequently), as before;
    2. WebGL (texImage2D + readPixels), one context per page;
    3. a GPU-backed 2D canvas.

    A frame that reads back empty, or all one colour (black, or the green of a zeroed frame), is tried the other ways, at most twice a second. The first way that gives a picture is kept. Until a video has shown a real picture, blank frames aren't published.

    • Why not just drop willReadFrequently: Chrome moves a 2D canvas that is read back every frame to the CPU after a few readbacks. A GPU-backed 2D canvas alone would change only the first frames. WebGL stays on the GPU.
    • A black frame after a real one is the video's own (a fade), so it is shown.
  • A play refused for want of a tap (NotAllowedError) is retried on the next tap or key anywhere on the page, inside that gesture. Before, it stayed paused until Play was pressed, and nothing said so.

  • Loading suspended before any data arrived (preload none, as Chrome does on Data Saver and some phones) now reports ready, so autoplay starts it. Before, it stayed loading forever, because autoplay waits for ready. A small file fetched whole is also suspended before its metadata; the progress event tells the two apart.

  • New Player::notice() (default "") says what keeps the picture away:

    • tap to start it
    • no CORS: its pictures cannot be read
    • its frames come out black (2d, gl, gpu), with the ways tried
    • playing, no picture yet (readyState N)
  • Module.cvcMediaPaths (say ["gl"]), set before a player opens, picks another order. It is for trying one path.

The core (src/cvc/ariadne/ariadne.cpp)

A video: with no frame says why over its box (item_badge):

  • failed; with controls: false, the error itself, since there is no controls line to show it;
  • the player's notice;
  • or, after 3 s loading or playing with no frame, loading / playing.

It isn't shown once a frame has been, where the widget has its own badge:, in a box under 96 px (avatars, emoji), or in a terminal (where a badge is a line of its own).

Docs: §5.13. Test: MediaBadge.AVideoWithNoPictureSaysWhyOverItsBox.

Verified (not on Android)

  • Native (Windows, MSVC): ariadne_media_test 61/61 passed, the new test included. clang-format 18.1.8 is clean.
  • The JS (the EM_JS bodies through em++ -E, patched into the arigl-web 4.0.2 bundle). The rig: headless Chrome 157 with a D3D11 GPU, emulating a 390x844 phone (DPR 3, touch), running nicotina main against the stub tx.wtf.
    • The feed videos play on 2d. The element sits at (0,0), 2x2, under the canvas: elementFromPoint(1,1) is the canvas.
    • With gl or gpu forced, the testsrc frames come out the right way up, in the right colours.
    • A dead first path falls through to 2d.
    • A recorded all-black WebM: nothing published, and after 3 s the notice says its frames come out black (2d, gl, gpu). This turned up WebGL tinting the outer column green on a black frame, so the check now samples a pixel in from the edges.
    • Black, then a picture, then black: the black opening is withheld, the picture shows from 1 s, the path stays 2d, and the late black frames show.
    • An unmuted play before any tap: blocked, with tap to start it. A tap anywhere on the page then plays it, with sound.
    • preload=none: the player says ready, and plays on play(). preload=auto is unaffected (a small file suspends before its metadata too, after a progress).
  • A real wasm build of this branch (arigl, the arigl-web shell), on the same rig:
    • Phone emulation and desktop (1280x900, no emulation): the feed videos play on 2d, with no console errors.
    • With Module.cvcMediaPaths = ["bogus"], after 3 s both feed video boxes say its frames come out empty (bogus none) over the placeholder.

Not verified

  • Anything on a real Android phone, or on iOS. Whether any of these is the actual cause is unknown until Joe's phone runs a release with it.
  • Hardware-decoded frames: the black-frame fallback was exercised with a recorded black WebM and a dead path, not with a real decoder that hands back black.
  • The terminal hosts: the badge isn't drawn there, and ari-media wasn't rebuilt here.

…ox says why there's no picture

Joe's Android phone shows nicotina's feed videos as a blank box (arigl-web 4.0.2); desktop
Chromium plays them. These are guesses, untested on a phone:

- media_browser.cpp: the hidden <video> sits in the viewport's top-left corner (2 px, under the
  canvas, opacity 0.01) instead of at left -10000px.
- A frame is read back with the 2D canvas kept in memory, else WebGL (texImage2D + readPixels,
  one context per page), else a GPU-backed 2D canvas. A frame that reads back empty or all one
  colour is tried the other ways (twice a second at most) and the first that gives a picture is
  kept; until a video has shown one, blank frames aren't published.
- A play refused for want of a tap is retried on the next tap or key anywhere on the page.
- Loading suspended before any data (preload none, Data Saver) reports ready, so autoplay starts
  it.
- Player::notice() (default ""): what keeps the picture away (tap to start it, frames that come
  out black and the ways tried, playing with no picture yet).
- ariadne.cpp: a video: with no frame says why over its box (item_badge): failed (the error with
  controls: false), the player's notice, or after 3 s loading or playing, that state. Not with
  its own badge:, in a box under 96 px, or in a terminal.

Docs: ARIADNE.md §5.13. Test: MediaBadge.AVideoWithNoPictureSaysWhyOverItsBox.
@transfix
transfix merged commit 84e790e into master Nov 21, 2026
30 checks passed
@transfix
transfix deleted the fix/ariadne-browser-video-android branch November 21, 2026 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant