Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The authoritative dependency lock is

| Component | Exact revision | Shipped form | License |
| --- | --- | --- | --- |
| AetherEngine 7.56.0 and upstream `main` through `a6fbf0a1` + Silo subtitle, HLS authorization and playback recovery patches, every optional component off | `f470d8dc610537929c83ef31877287e9d2ad9d28` | Swift package target linked into each host app | LGPL-3.0-only with AetherEngine's Apple Store / DRM exception |
| AetherEngine 7.56.0 and upstream `main` through `a6fbf0a1` + Silo subtitle, HLS authorization and playback recovery patches, every optional component off | `db3125af433a443f85f9914b211dd9b3dbc1e4c3` | Swift package target linked into each host app | LGPL-3.0-only with AetherEngine's Apple Store / DRM exception |
| FFmpegBuild 3.12.1 | `9c87af0231fd1403654c14a0e867fe8aa43c5bea` | Nine separately embedded dynamic frameworks | See the component table below |
| LibDovi 2.1.0 | `0d7cce1d6836a30d13a3a2326e50a153af53f014` | Static `Dovi.xcframework` linked through AetherEngine | MIT packaging; embedded libdovi is MIT |
| Nuke and NukeUI 13.2.0 | `30f7a7e72e0607d304fbf69c799474bd5fb6d1ce` | Swift package targets linked into each host app | MIT |
Expand Down Expand Up @@ -52,7 +52,7 @@ published under the LGPL at the exact source revision below. The bundled
acknowledgements include AetherEngine's complete license and exception plus
the GNU GPL version 3 text incorporated by LGPLv3.

- Exact source: <https://github.com/Silo-Server/AetherEngine/tree/f470d8dc610537929c83ef31877287e9d2ad9d28>
- Exact source: <https://github.com/Silo-Server/AetherEngine/tree/db3125af433a443f85f9914b211dd9b3dbc1e4c3>
(engine pull requests: <https://github.com/Silo-Server/AetherEngine/pull/2>,
<https://github.com/Silo-Server/AetherEngine/pull/6>,
<https://github.com/Silo-Server/AetherEngine/pull/15>,
Expand All @@ -65,7 +65,10 @@ the GNU GPL version 3 text incorporated by LGPLv3.
<https://github.com/Silo-Server/AetherEngine/pull/23>,
<https://github.com/Silo-Server/AetherEngine/pull/24>,
<https://github.com/Silo-Server/AetherEngine/pull/25>,
<https://github.com/Silo-Server/AetherEngine/pull/26>)
<https://github.com/Silo-Server/AetherEngine/pull/26>,
<https://github.com/Silo-Server/AetherEngine/pull/27>,
<https://github.com/Silo-Server/AetherEngine/pull/30>,
<https://github.com/Silo-Server/AetherEngine/pull/31>)
- Upstream base: <https://github.com/superuser404notfound/AetherEngine/tree/a6fbf0a1c469df98df66d886482b9f062cdab7f8>
- Rebuild input: `Package.swift` and the source tree at that revision
- Bundled texts: `AetherEngine-LGPL-3.0-App-Store-Exception.txt`,
Expand Down
8 changes: 4 additions & 4 deletions iosApp/Resources/OpenSourceLicenses/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ texts are bundled beside this file and are available from Settings > About >
Acknowledgements.

AetherEngine
Revision: f470d8dc610537929c83ef31877287e9d2ad9d28 (upstream release
Revision: db3125af433a443f85f9914b211dd9b3dbc1e4c3 (upstream release
7.56.0 and upstream main through commit a6fbf0a1, plus Silo patches for
subtitle renditions, source timing, primary ASS routing with normalized
secondary/PiP text, refreshable authorization for native HLS, sidecar
subtitles and fonts, truncated sidecar refetch, dense subtitle catch-up,
audio-switch tracking, playback recovery, and resuming forward-only
sources)
audio-switch tracking, playback recovery, resuming forward-only
sources, relayed media timing, and faster cold starts)
License: GNU LGPL version 3 with the upstream Apple Store / DRM exception
Source (modified, as built): https://github.com/Silo-Server/AetherEngine/tree/f470d8dc610537929c83ef31877287e9d2ad9d28
Source (modified, as built): https://github.com/Silo-Server/AetherEngine/tree/db3125af433a443f85f9914b211dd9b3dbc1e4c3
Upstream base: https://github.com/superuser404notfound/AetherEngine/tree/a6fbf0a1c469df98df66d886482b9f062cdab7f8
Rebuild: the Package.swift and source tree at that revision, with its
default package traits, which leave every optional component out: TrueHD
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions iosApp/Tests/AetherPlaybackBoundaryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,40 @@ final class AetherPlaybackBoundaryTests: XCTestCase {
XCTAssertFalse(spec.options.audioOnly)
XCTAssertFalse(spec.options.autoplay)
XCTAssertFalse(spec.options.nativeRemoteHLS)
XCTAssertTrue(spec.options.progressiveSegmentDelivery)
XCTAssertEqual(spec.options.probesize, 4 * 1024 * 1024)
XCTAssertEqual(spec.options.maxAnalyzeDuration, 2_000_000)
XCTAssertTrue(spec.options.skipsContainerAttachments)
}

/// The bounded probe skips sparse tracks a Matroska or MP4 header already
/// describes. An MPEG-TS or M2TS original states its stream parameters
/// only in packets, so it keeps the engine's default budget.
func testBoundedProbeOnlyForContainersWhoseHeaderDescribesTheStreams() throws {
for (container, bounded) in [("mkv", true), ("mp4", true), ("ts", false), ("m2ts", false)] {
var object = try PlaybackV3FixtureTestSupport.v2DecisionObject(bundleClass: Self.self)
var planObject = try XCTUnwrap(object["playback_plan"] as? [String: Any])
var stream = try XCTUnwrap(planObject["stream"] as? [String: Any])
stream["container"] = container
planObject["stream"] = stream
object["playback_plan"] = planObject
guard case .playable(let plan, let sessionID) = try PlaybackV3FixtureTestSupport.v2Decision(object)
.validatedForApple() else {
return XCTFail("Expected a playable \(container) fixture")
}
let spec = try AetherLoadSpec(
validating: plan,
sessionID: sessionID,
matchContentEnabled: true,
resolveURL: { URL(string: $0, relativeTo: URL(string: "https://dev.example.test")) }
)
XCTAssertEqual(spec.options.probesize, bounded ? AetherLoadSpec.networkProbeSizeBytes : nil, container)
XCTAssertEqual(
spec.options.maxAnalyzeDuration,
bounded ? AetherLoadSpec.networkMaxAnalyzeDurationMicros : nil,
container
)
}
}

func testServerHLSUsesAetherAuthenticatedRemoteBypass() throws {
Expand Down
123 changes: 123 additions & 0 deletions iosApp/Tests/PlayerSettingsFlushTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1971,6 +1971,125 @@ final class PlayerSettingsFlushTests: XCTestCase {
"a resolved default is an answer, not a missing one")
}

func testRefreshFromServerIfStaleReusesFreshScopeAndRefreshesWhenScopeChanges() async throws {
let suiteName = "player-settings-stale-test-\(UUID().uuidString)"
let defaults = try XCTUnwrap(UserDefaults(suiteName: suiteName))
defer { UserDefaults().removePersistentDomain(forName: suiteName) }

let transport = FakeSettingsTransport()
transport.effective = [
.init(key: SettingKey.playbackAutoSkipCredits.rawValue, value: .bool(true), source: .scope(.profileDevice), scope: .profileDevice)
]
var activeScope = "scope-a"
let settings = PlayerSettings(
defaults: defaults,
flusher: PlayerSettingsFlusher(transport: transport, debounce: .milliseconds(10)),
scopeIdentifier: { activeScope }
)

let first = await settings.refreshFromServerIfStale(maxAge: 300)
XCTAssertEqual(first, .refreshed)
let callsAfterFirst = transport.effectiveCalls().count
XCTAssertGreaterThan(callsAfterFirst, 0)

let second = await settings.refreshFromServerIfStale(maxAge: 300)
XCTAssertEqual(second, .refreshed)
XCTAssertEqual(transport.effectiveCalls().count, callsAfterFirst, "fresh scope must not hit the server again")

activeScope = "scope-b"
let third = await settings.refreshFromServerIfStale(maxAge: 300)
XCTAssertEqual(third, .refreshed)
XCTAssertGreaterThan(transport.effectiveCalls().count, callsAfterFirst, "scope change must refresh from server")
}

/// A refresh that left a read unanswered, or that put another scope's
/// cache on screen, leaves nothing for the next Play to reuse.
func testRefreshFromServerIfStaleRereadsAfterAnIncompleteOrForeignRefresh() async throws {
let suiteName = "player-settings-stale-incomplete-\(UUID().uuidString)"
let defaults = try XCTUnwrap(UserDefaults(suiteName: suiteName))
defer { UserDefaults().removePersistentDomain(forName: suiteName) }

let transport = FakeSettingsTransport()
transport.effective = [
.init(key: SettingKey.playbackAutoSkipCredits.rawValue, value: .bool(true), source: .scope(.profileDevice), scope: .profileDevice)
]
let scope = LockedScopeValue("scope-a")
let settings = PlayerSettings(
defaults: defaults,
flusher: PlayerSettingsFlusher(transport: transport, debounce: .milliseconds(10)),
scopeIdentifier: { scope.value }
)

// The buffering batch fails, so this refresh is not a fresh answer.
transport.onEffectiveValues = { keys in
if keys == SettingKey.playerBufferingQualitySettings {
transport.effectiveError = .transport(description: "offline")
}
}
let incomplete = await settings.refreshFromServerIfStale(maxAge: 300)
XCTAssertEqual(incomplete, .refreshed)
transport.onEffectiveValues = nil
transport.effectiveError = nil
var calls = transport.effectiveCalls().count
let afterIncomplete = await settings.refreshFromServerIfStale(maxAge: 300)
XCTAssertEqual(afterIncomplete, .refreshed)
XCTAssertGreaterThan(transport.effectiveCalls().count, calls, "an unanswered read must be asked again")

calls = transport.effectiveCalls().count
_ = await settings.refreshFromServerIfStale(maxAge: 300)
XCTAssertEqual(transport.effectiveCalls().count, calls, "a complete refresh is reused")

// Scope B's failed refresh puts B's cache on screen; A must be read
// again rather than trusting A's stamp.
scope.value = "scope-b"
transport.effectiveError = .transport(description: "offline")
let failedB = await settings.refreshFromServer()
XCTAssertEqual(failedB, .unavailable)
transport.effectiveError = nil
scope.value = "scope-a"
calls = transport.effectiveCalls().count
_ = await settings.refreshFromServerIfStale(maxAge: 300)
XCTAssertGreaterThan(transport.effectiveCalls().count, calls, "A's values are no longer the live ones")
}

/// A Play that starts while the same scope's refresh is still reading
/// waits for that refresh instead of sending its own.
func testRefreshFromServerIfStaleWaitsForARefreshAlreadyRunning() async throws {
let suiteName = "player-settings-stale-overlap-\(UUID().uuidString)"
let defaults = try XCTUnwrap(UserDefaults(suiteName: suiteName))
defer { UserDefaults().removePersistentDomain(forName: suiteName) }

let transport = FakeSettingsTransport()
transport.effective = [
.init(key: SettingKey.playbackAutoSkipCredits.rawValue, value: .bool(true), source: .scope(.profileDevice), scope: .profileDevice)
]
let gate = SettingsWriteGate()
transport.effectiveGate = gate
await gate.block()
let settings = PlayerSettings(
defaults: defaults,
flusher: PlayerSettingsFlusher(transport: transport, debounce: .milliseconds(10)),
scopeIdentifier: { "scope-a" }
)

let running = Task { await settings.refreshFromServer() }
await gate.waitUntilEntered()
let play = Task { await settings.refreshFromServerIfStale(maxAge: 300) }
await Task.yield()
await gate.release()

let runningResult = await running.value
let playResult = await play.value
XCTAssertEqual(runningResult, .refreshed)
XCTAssertEqual(playResult, .refreshed)
XCTAssertEqual(transport.effectiveCalls().filter { $0 == SettingKey.playerReadSettings }.count, 1,
"the running refresh answers the Play")

let calls = transport.effectiveCalls().count
_ = await settings.refreshFromServerIfStale(maxAge: 300)
XCTAssertEqual(transport.effectiveCalls().count, calls, "the shared refresh stamped the scope fresh")
}

func testRefreshResolvesTheQualityTierFromBothAxes() async throws {
let harness = try PlayerSettingsHarness()

Expand Down Expand Up @@ -2566,6 +2685,9 @@ final class FakeSettingsTransport: PlayerSettingsTransport, @unchecked Sendable
/// Invoked as each delete is attempted, before its outcome is decided.
var onDelete: ((Delete) -> Void)?
let writeGate = SettingsWriteGate()
/// When set, each `effectiveValues` call waits here first, so a test can
/// hold a refresh mid-read.
var effectiveGate: SettingsWriteGate?

private let lock = NSLock()
private var recordedWrites: [Write] = []
Expand Down Expand Up @@ -2641,6 +2763,7 @@ final class FakeSettingsTransport: PlayerSettingsTransport, @unchecked Sendable
// MARK: PlayerSettingsTransport

func effectiveValues(keys: [SettingKey]) async throws -> EffectiveSettingValuesResponse {
if let effectiveGate { await effectiveGate.waitIfBlocked() }
onEffectiveValues?(keys)
lock.lock()
recordedEffectiveCalls.append(keys)
Expand Down
43 changes: 42 additions & 1 deletion iosApp/iosApp/Screens/Player/AetherLoadSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,36 @@ struct AetherLoadSpec {
/// selection, and none needs a sidecar.
let hlsSubtitleRenditions: [Int64: HLSSubtitleRenditionSlot]

/// Bounded demux probe limits for network VOD loads (4 MiB / 2 s). Keeps
/// `avformat_find_stream_info` from scanning up to 50 MiB / 60 s chasing
/// sparse bitmap subtitle tracks before first frame.
static let networkProbeSizeBytes: Int64 = 4 * 1024 * 1024
static let networkMaxAnalyzeDurationMicros: Int64 = 2 * 1_000_000

/// Whether a load may take the bounded probe. Only a network source whose
/// container header describes every stream (Matroska, MP4/MOV) does: an
/// MPEG-TS or M2TS source states its stream parameters only in packets,
/// and a local file has no network cost to save. An unknown container
/// keeps the engine default.
static func boundsDemuxProbe(sourceURL: URL, container: String?) -> Bool {
guard !sourceURL.isFileURL, let container else { return false }
return ["mkv", "matroska", "webm", "mp4", "m4v", "mov"].contains(container.lowercased())
}

/// Whether an original-file load may need container-embedded font
/// attachments for ASS/SSA rendering. When false, opening with
/// `skipsContainerAttachments` avoids reading embedded fonts and cover art
/// before the first video packet.
static func needsContainerFontAttachments(for plan: PlaybackV3Plan) -> Bool {
guard plan.delivery == PlaybackProtocolV3.PlanDelivery.originalHTTP else { return false }
return plan.subtitle.inventory.contains { item in
guard item.source == "embedded" else { return false }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Keep attachments for sidecar ASS tracks without bundles.

For an original Matroska file with attached fonts and an external ASS track without a bundle, this guard skips the attachments. ASSSubtitleSession.prepareFonts previously used those attachments for sidecars too. The sidecar now loses its authored fonts. Include such tracks when deciding whether to keep attachments.

let codec = (item.codec ?? "").lowercased()
let isASS = codec == "ass" || codec == "ssa" || codec == "substation"
return isASS && item.fontBundleUrl == nil

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Heavy lift

Preserve a fallback when the font bundle fails.

For a selected embedded ASS track with a bundle URL, this skips the container fonts. If the bundle request fails, prepareFonts records a failure and stops drawing subtitles until the selection changes. Previously, it used the container fonts without making that request. Keep the attachments or provide a recovery path for a failed bundle request.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Register font bundles for embedded tracks before skipping attachments

When original-file playback starts with subtitles off (or a non-ASS track selected), an embedded ASS track with a fontBundleUrl now causes container attachments to be skipped, but AetherLoadSpec.subtitleFontRequests only registers the initially selected track's bundle. Selecting that ASS track later uses registerEmbeddedSubtitleTrack, which registers no font request and bypasses the sidecar path. Consequently, ASSSubtitleSession.prepareFonts has neither container fonts nor a bundle request, so subtitles lose their authored fonts and can display missing glyphs. Register bundle requests when mounting embedded tracks, or retain attachments until every locally selectable ASS track has a working font-loading path.

Useful? React with 👍 / 👎.

}
}

/// The bridge for codecs Aether cannot stream-copy, when a caller does not
/// name one. Lossless rather than Aether's `.surroundCompat` default;
/// `PlayerSettings.losslessAudioEnabled` overrides it.
Expand Down Expand Up @@ -298,6 +328,7 @@ struct AetherLoadSpec {
preferredSubtitleLanguages: preferredSubtitleLanguages,
externalSubtitles: externalSubtitles,
forwardBufferSegments: forwardBufferSegments,
progressiveSegmentDelivery: !audioOnly,
autoplay: false,
deinterlaceMode: deinterlaceMode,
deinterlaceFieldRate: deinterlaceFieldRate
Expand Down Expand Up @@ -369,6 +400,7 @@ struct AetherLoadSpec {
externalSubtitleAppTrackIDs = sidecars.map { sidecar -> Int64? in
SubtitleTrackIdSpace.makeSidecarTrackId(urlIndex: sidecar.index)
}
// No container is known here (online loads take a v3 plan); keep the default probe.
options = LoadOptions(
httpHeaders: headers,
dolbyVisionHandling: dolbyVisionHandling,
Expand All @@ -384,6 +416,7 @@ struct AetherLoadSpec {
preferredSubtitleLanguages: preferredSubtitleLanguages,
externalSubtitles: externalSubtitles,
forwardBufferSegments: forwardBufferSegments,
progressiveSegmentDelivery: !audioOnly,
autoplay: false,
deinterlaceMode: deinterlaceMode,
deinterlaceFieldRate: deinterlaceFieldRate
Expand Down Expand Up @@ -560,6 +593,10 @@ struct AetherLoadSpec {
delivery: plan.delivery, hasVideo: plan.effectiveRecipe.videoCodec != nil
)
self.requestHeaderResolver = resolvesRequestCredentials && !isServerHLS ? requestHeaderResolver : nil
let hasVideo = plan.effectiveRecipe.videoCodec != nil
// Server HLS is opened by AVPlayer, not probed by Aether's demuxer.
let boundsProbe = !isServerHLS
&& Self.boundsDemuxProbe(sourceURL: sourceURL, container: plan.stream.container)
var loadOptions = LoadOptions(
httpHeaders: effectiveHeaders,
httpRequestAuthorization: resolvesRequestCredentials ? requestAuthorization : nil,
Expand All @@ -568,7 +605,7 @@ struct AetherLoadSpec {
panelIsInHDRMode: panelIsInHDRMode ?? AetherDisplayContext.panelIsInHDRMode,
audioBridgeMode: audioBridgeMode,
objectAudioRendering: objectAudioRendering,
audioOnly: plan.effectiveRecipe.videoCodec == nil,
audioOnly: !hasVideo,
nativeRemoteHLS: isServerHLS,
preserveASSMarkup: true,
prepareNativeSubtitles: true,
Expand All @@ -577,10 +614,14 @@ struct AetherLoadSpec {
// planning input, not permission for the engine to select a
// different embedded or inventory track after the plan arrives.
nativeSubtitlePreferredLanguages: [],
probesize: boundsProbe ? Self.networkProbeSizeBytes : nil,
maxAnalyzeDuration: boundsProbe ? Self.networkMaxAnalyzeDurationMicros : nil,
skipsContainerAttachments: !Self.needsContainerFontAttachments(for: plan),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Register font bundles for later embedded ASS selections before skipping attachments.

If subtitles start off and an embedded ASS track has fontBundleUrl, this skips the container fonts. However, subtitleFontRequests contains only the initially selected track.

When the viewer later selects that ASS track, registerProtocolV3EmbeddedSubtitleIfAvailable takes the native path. registerEmbeddedSubtitleTrack binds the IDs but does not register the font request. ASSSubtitleSession.prepareFonts then finds neither container fonts nor a bundle request. The track loses its authored fonts for that session.

Register the bundle on native embedded selection, or retain container attachments until that path supports bundles.

preferredAudioLanguages: preferredAudioLanguages,
preferredSubtitleLanguages: [],
externalSubtitles: externalSubtitles,
forwardBufferSegments: forwardBufferSegments,
progressiveSegmentDelivery: !isServerHLS && hasVideo,
autoplay: false,
deinterlaceMode: deinterlaceMode,
deinterlaceFieldRate: deinterlaceFieldRate
Expand Down
Loading
Loading