Automattic / Automattic/pocket-casts-ios

Playback time: currentTime() not changing

Open
#13 0 comments 0 reactions 0 assignees View on GitHub
[Type] Bug playback
Dominant language
Swift
Stars
1.8k
Forks
197
Avg merge
17h 20m
Merged PRs (30d)
103

Description

A user is having an issue with the playback time not changing. Related: 4576716-zd-woothemes

### Additional information

In `PlaybackManager` currentTime is determined like so:

```
func currentTime() -> TimeInterval {
guard let episode = currentEpisode() else { return -1 }

if seekingTo >= 0, seekingTo <= duration(), !playing() { return seekingTo }

let playerTime = !aboutToPlay.value ? player?.currentTime() ?? 0 : 0

if playerTime <= 0 {
let startFromTime = startFromTimeForCurrentEpisode()
return episode.playedUpTo < 1 ? startFromTime : episode.playedUpTo
}

return playerTime
}
```

In the report is informed that this time gets "stuck", you can see it in their logs:

```
2021-12-07 10:10:58 saving played up to 1.38 for episode Consider the lobstermen
2021-12-07 10:10:59 Sent position 1 status 2 for episode Consider the lobstermen to server
2021-12-07 10:11:30 saving played up to 1.38 for episode Consider the lobstermen
2021-12-07 10:12:02 saving played up to 1.38 for episode Consider the lobstermen
2021-12-07 10:12:34 saving played up to 1.38 for episode Consider the lobstermen
2021-12-07 10:13:06 saving played up to 1.38 for episode Consider the lobstermen
2021-12-07 10:13:06 Sent position 1 status 2 for episode Consider the lobstermen to server
2021-12-07 10:13:38 saving played up to 1.38 for episode Consider the lobstermen
2021-12-07 10:14:10 saving played up to 1.38 for episode Consider the lobstermen
2021-12-07 10:14:42 saving played up to 1.38 for episode Consider the lobstermen
2021-12-07 10:15:14 saving played up to 1.38 for episode Consider the lobstermen
2021-12-07 10:15:14 Sent position 1 status 2 for episode Consider the lobstermen to server
2021-12-07 10:15:46 saving played up to 1.38 for episode Consider the lobstermen
2021-12-07 10:16:18 saving played up to 1.38 for episode Consider the lobstermen
```

I can see this happening in the code above if the `seekingTo` time is still set or `aboutToPlay` both of which might be subject to either race conditions or a path we haven't coded for.

Contributor guide

Open the contributing guide

Research direction

Start at PlaybackManager.currentTime(), then trace the seekingTo, aboutToPlay, player.currentTime(), and playedUpTo states against the supplied logs. Reproduce the stuck playback-time report and determine which state remains active; done means currentTime() advances during playback and the logged saved positions increase normally.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
audio-video-rtc, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.