Skip to content

fix(ios): Rebuild decode pipeline and restore hwdec on iOS resume from background#1961

Open
5ext9fca wants to merge 5 commits into
bggRGjQaUbCoE:devfrom
5ext9fca:fix/ios-hwdec
Open

fix(ios): Rebuild decode pipeline and restore hwdec on iOS resume from background#1961
5ext9fca wants to merge 5 commits into
bggRGjQaUbCoE:devfrom
5ext9fca:fix/ios-hwdec

Conversation

@5ext9fca

@5ext9fca 5ext9fca commented May 3, 2026

Copy link
Copy Markdown

Fixes #1960

Summary

On iOS, returning the app to the foreground could leave hardware decode in a bad state. This change rebuilds the decode path on resume by reapplying hwdec, reopening the current item at the saved position, restoring playback speed and UI position, and resuming playback when appropriate.

Details

  • PlPlayerController: Add _recoverIosHwdecAfterResume (guarded by platform, hwdec, non-empty current, and a re-entrancy flag) and a public onAppResumed({shouldResumePlayback}) entry point.
  • PLVideoPlayer lifecycle: On AppLifecycleState.resumed, call onAppResumed on iOS (non-blocking). Non‑iOS still uses a simple play() when playback had been paused due to backgrounding. Pause-on-background behavior is unchanged for the “don’t continue in background” case.

Test plan

  • iPhone (physical device): play with hardware decode → background → foreground; decode/video recovers without needing a manual workaround.

Copilot AI review requested due to automatic review settings May 3, 2026 09:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses the iOS-specific playback regression reported in #1960 by moving foreground-resume handling into the shared player controller and rebuilding the decode pipeline so hardware decoding can be restored after the app returns from background.

Changes:

  • Update PLVideoPlayer lifecycle handling to pause on background and delegate iOS foreground recovery to the controller.
  • Add PlPlayerController.onAppResumed() and an iOS-only hwdec recovery path that reopens the current media at the saved position.
  • Preserve the simpler non-iOS resume behavior while keeping existing pause-on-background behavior for the no-background-play case.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
lib/plugin/pl_player/view/view.dart Changes app lifecycle handling so iOS resume flows through controller-driven recovery instead of direct play().
lib/plugin/pl_player/controller.dart Adds the iOS hwdec recovery routine that reapplies decoder settings, reopens media, restores playback state, and conditionally resumes playback.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/plugin/pl_player/controller.dart
Comment thread lib/plugin/pl_player/controller.dart
Comment thread lib/plugin/pl_player/view/view.dart Outdated
Comment thread lib/plugin/pl_player/view/view.dart Outdated
Comment thread lib/plugin/pl_player/controller.dart
Comment thread lib/plugin/pl_player/controller.dart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants