Skip to content

loadRemoteHLS never attaches the player layer to an already-bound surface (black video, audio plays) #120

Closed

Description

@dlev02

Hit this while testing live IPTV channels through the nativeRemoteHLS path: video is completely black but audio plays fine, on every channel.

Looking at the flow, I think the bypass just never presents its layer. bind(view:) calls presentCurrentLayer() at bind time, and the normal load() native/software paths call it again after the host exists. But loadRemoteHLS sets self.nativeHost = host and early-returns before those calls — so if the surface was bound before load (the usual SwiftUI order: the view appears, then the load task fires), presentCurrentLayer() ran when nativeHost was still nil and nothing ever attaches host.playerLayer afterwards. AVPlayer happily plays audio without a layer, which makes it look like a codec problem when it's really just a missing attach.

Repro:

  1. AetherPlayerSurface(engine:) on screen first (engine bound, nothing loaded).
  2. load(url:options:) with isLive = true, nativeRemoteHLS = true and any live HLS URL.
  3. Audio plays, view stays black. Same load with the surface created after load renders fine, since the fresh bind presents the by-then-existing host layer.

Suggested fix: call presentCurrentLayer() in loadRemoteHLS once the host is assigned (mirroring what loadNative does). I'm working around it host-side for now by re-creating the surface view after the load completes so a fresh bind runs, but that's a hack I'd love to delete.

Activity

  1. dlev02 commented on Jul 10, 2026

    @dlev02
    ContributorAuthor

    For context: #119 is in the same nativeRemoteHLS path (headers dropped at asset creation). Separate fix, but worth looking at together if you're in that code anyway.

  2. superuser404notfound commented on Jul 10, 2026

    @superuser404notfound
    Owner

    Confirmed, and your analysis was spot on. loadRemoteHLS assigned the host and early-returned without ever calling presentCurrentLayer(), so a surface bound before load ran the bind-time present while nativeHost was still nil and nothing attached the layer afterwards. Your SwiftUI ordering (view appears, then the load task fires) is exactly the sequence that hits it.

    Fixed on main in c283b4c: presentCurrentLayer() now runs right after the host is assigned, mirroring what loadNative does. The attach is idempotent, so the post-bind and host-reuse cases are unchanged. There is also a unit test now that locks the pre-bound-surface contract (it reproduced your black-video case 1:1 before the fix).

    You should be able to delete the surface-recreation workaround. Please give main a spin, and thanks for the precise report, both here and in #119.

  3. added a commit that references this issue on Jul 10, 2026
  4. superuser404notfound commented on Jul 10, 2026

    @superuser404notfound
    Owner

    Tagged and released: both this fix and #119 shipped in 5.0.1, so you can pin the release tag instead of main for the retest.

  5. dlev02 commented on Jul 10, 2026

    @dlev02
    ContributorAuthor

    Retested on 5.0.1, fixed. I deleted my surface-recreation workaround entirely, pointed the player at a live IPTV channel with the surface on screen before load (the exact ordering that black-screened), and video renders immediately, frames advancing. Nice touch adding the unit test for the pre-bound contract. Thanks for the fast turnaround, closing.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions