Skip to content

Does a mediaPlayback foreground service keep Cup's WebView audio and network alive on the Android emulator? #373

Closed

Description

@patricktree

Question

On the mobile E2E suite's Android emulator, does a mediaPlayback foreground service keep Cup's WebView <audio> playing and Cup's requests to https://cup.audio succeeding while Cup is in the background for at least 10 minutes? Does the narration track's signed URL serve range requests from the https://localhost origin through a whole listen?

Use a throwaway stub plugin that starts the service on Play while Cup is visible; nothing of it is kept. The Android background network access research gives the baseline without a service, its probes and their reproduction. Record:

  • Process state and isFrozen
  • Audio position and buffered end over time
  • Outcomes of requests to cup.audio through CapacitorHttp and fetch
  • Whether the renderer process survives
  • The narration track's range requests: their status, and whether they keep working

Talk to production https://cup.audio, not a loopback test Worker, because loopback is exempt from the network cut. Use only public or test-account data.

Activity

  1. self-assigned this
    on Nov 14, 2026
  2. patricktree commented on Nov 14, 2026

    @patricktree
    CollaboratorAuthor

    Resolution

    Yes, on the emulator. Research: Android mediaPlayback foreground service and WebView playback (branch research/android-foreground-service-playback, with a probe archive that holds the stub plugin's source).

    I tested on cup-mobile-e2e-api36-ram4g (Android 16, WebView 133) with a throwaway stub plugin. It starts a mediaPlayback foreground service on Play while Cup is visible. The debug build talked to production https://cup.audio. The test pressed HOME, turned the screen off 60 s later, and left Cup in the background for 11 minutes.

    • Process state and isFrozen: with the service, Cup and its WebView renderer stayed at process state 4 with isFrozen=false at every 30 s sample. Without it, on the same setup, both went to state 15 and were frozen 90 s after HOME, as in the baseline.
    • Audio: the public-domain LibriVox MP3 played for the whole 11 minutes. While Cup was hidden with the screen off, the WebView refilled its buffer three times, from 414 s to 1133 s buffered. Without the service, playback stopped at 84 s when Android froze Cup.
    • Requests to cup.audio: with the service, all 88 background GET / requests (44 through CapacitorHttp, 44 through fetch) returned 200. Without it, the first background request, 14 s after HOME, already failed with UnknownHostException.
    • Renderer: survived every service run with the same process ID.
    • Signed track URL from https://localhost: tested against the local test Worker, signed in through the fake Google sign-in. That checks authorization only, because loopback is exempt from the network cut. The WebView's <audio> got 206 for bytes=0- at the start, and again about 3.5 minutes later with Cup hidden and the screen off. A seek to near the end made it send bytes=262144-, also answered 206 with the matching Content-Range, about 28 minutes after the URL was issued. The media requests carry no Origin, so only the token authorizes them.

    Limits:

    • No physical device and no Doze.
    • The narration track was the test Worker's 19 s fake track.
    • A first run with the emulator's network throttled to 80 kbps stalled when its buffer ran out. Unthrottled reruns and shorter refill checks did not reproduce the stall, so it is most likely an artifact of the throttling, but that is not proven.
    • Once the page is silent, Chrome's intensive timer throttling still applies to it even with the service running.

    🤖 Generated with Claude Code

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions