diag: add stop-time tracks check to detect HLS variant switching

This commit is contained in:
yumoqing 2026-06-28 10:14:32 +08:00
parent 1eff22a1ad
commit 4ba3ccde21

View File

@ -582,6 +582,36 @@ final class PlayerRecorder: NSObject {
statsSnapshot.videoFrames, statsSnapshot.processCallCount, statsSnapshot.appendCount,
statsSnapshot.peakAmplitude, statsSnapshot.activeCallCount, statsSnapshot.silentCallCount)
// tracks
if let pi = currentPlayerItem, let boundID = tapContext?.mixTrackID {
let currentTracks = pi.tracks
NSLog("[Recorder:DIAG] Stop-time tracks: count=%d", currentTracks.count)
var stopLog = "\n=== Stop-time tracks check ===\n"
stopLog += "Bound trackID: \(boundID)\n"
stopLog += "Current tracks count: \(currentTracks.count)\n"
var foundBoundTrack = false
for (i, t) in currentTracks.enumerated() {
let tid = t.assetTrack?.trackID ?? -1
let mtype = t.assetTrack?.mediaType.rawValue ?? "?"
NSLog("[Recorder:DIAG] stopTrack[%d]: trackID=%d mediaType=%@ enabled=%d", i, tid, mtype, t.isEnabled)
stopLog += " track[\(i)]: trackID=\(tid) mediaType=\(mtype) enabled=\(t.isEnabled)\n"
if tid == boundID {
foundBoundTrack = true
}
}
stopLog += "Bound trackID \(boundID) still exists: \(foundBoundTrack)\n"
NSLog("[Recorder:DIAG] Bound trackID=%d still exists: %d", boundID, foundBoundTrack)
//
if let moviesDir = FileManager.default.urls(for: .moviesDirectory, in: .userDomainMask).first {
let logPath = moviesDir.appendingPathComponent("MiniPlayer/tap_install_log.txt")
if let handle = try? FileHandle(forWritingTo: logPath) {
handle.seekToEndOfFile()
handle.write(stopLog.data(using: .utf8)!)
handle.closeFile()
}
}
}
currentPlayerItem = nil
videoInput?.markAsFinished()