Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip Back: do not allow skipping forward when skipping back #2041

Merged
merged 5 commits into from
Aug 16, 2024

Conversation

leandroalonso
Copy link
Member

Fixes #1950

Adds a mechanism to ensure that rapidly tapping Skip Back do not result in skipping forward.

This doesn't actually fixes the issue but prevents it from happening.

To test

I highly recommend testing on a real device. In order to reproduce the issue and test this PR you need:

  1. To download an episode
  2. To enable trim silence
  3. Then, play the episode

Then:

  1. Open the full screen player.
  2. Tap the play button.
  3. Tap the "skip back" button in rapid succession.
  4. ✅ The audio should skip back, not forward
  5. Skip forward
  6. ✅ It should work
  7. Skip forward, then back
  8. ✅ It should work

Checklist

  • I have considered if this change warrants user-facing release notes and have added them to CHANGELOG.md if necessary.
  • I have considered adding unit tests for my changes.
  • I have updated (or requested that someone edit) the spreadsheet to reflect any new or changed analytics.

@leandroalonso leandroalonso added the [Type] Bug Used for issues where something is not functioning as intended. label Aug 15, 2024
@leandroalonso leandroalonso added this to the 7.71 milestone Aug 15, 2024
@leandroalonso leandroalonso requested a review from a team as a code owner August 15, 2024 14:05
@leandroalonso leandroalonso requested review from SergioEstevao and removed request for a team August 15, 2024 14:05
@dangermattic
Copy link
Collaborator

dangermattic commented Aug 15, 2024

1 Warning
⚠️ This PR is assigned to the milestone 7.71. The due date for this milestone has already passed.
Please assign it to a milestone with a later deadline or check whether the release for this milestone has already been finished.

Generated by 🚫 Danger

// Here we handle that to avoid this issue
// See https://github.com/Automattic/pocket-casts-ios/issues/1950
if seekHint == .back {
if let previousSeekTime, time > previousSeekTime {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use the currentTime value that we have bellow? And avoid the use of this variable and the deboucer?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because it will never work.

currentTime is the wrong value being given. If we compare it to it, time > currentTime will never succeed. You can try adding and testing it, the bug will be there.

Not sure if the usage of debouncer is clear, if not I can add a comment clarifying it. But we have the debouncer to fix issues with skip forward or other seeks after rapidly tapping skipping back happens. If we don't have it, we might get stuck into a state where seek will never work.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just wanted to clarify if the currentTime returned is correct or not.
So our current understanding is that value sometimes is not correct/or not in sync with the previous seeks

Regarding the debouncer my understanding is that we want to clear the previousSeektime, so it's only used when you are doing multiple skips back in a quick interval. Right?

// skip back results (sometimes) in skipping forward
// Here we handle that to avoid this issue
// See https://github.com/Automattic/pocket-casts-ios/issues/1950
if seekHint == .back {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Could we refactor this to a separate method something like isValidSeek ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in 601a196

Copy link
Contributor

@SergioEstevao SergioEstevao left a comment

Choose a reason for hiding this comment

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

I tested this on simulator and real device and it looks that it avoid the bug of moving forward.
The only thing that I notice it that sometime the seekPosition get's "stucks: in a specific position ( I see that is because our fail guard kicks in) but it then starts moving again when the times resync.
All in all I think it's better than our current state so I think we should move forward with this solution.

@leandroalonso leandroalonso merged commit 3208694 into trunk Aug 16, 2024
4 of 6 checks passed
@leandroalonso leandroalonso deleted the fix/skip-back-skip-forward branch August 16, 2024 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug Used for issues where something is not functioning as intended.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rapidly Tapping Skip Back Button Results in App Skipping Forward
3 participants