Skip to content

[video_player_avplay] Handle consecutive seekTo calls - #1152

Open
gin7773 wants to merge 1 commit into
flutter-tizen:mainfrom
gin7773:avplay/seekTo
Open

gin7773 wants to merge 1 commit into
flutter-tizen:mainfrom
gin7773:avplay/seekTo

Conversation

@gin7773

@gin7773 gin7773 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Main changes:

Track active and pending seek operations in the Dart FFI implementation so only one native seek is in flight per player. Coalesce consecutive seekTo requests to the latest pending position, complete all waiting futures when the seek finishes, and fail pending seeks when the player is disposed or reports an error.

Send a seekCompleted event from native code so Dart can complete the active seek and start any pending seek.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e56086814f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +154 to +155
} catch (e) {
_completeSeekWithError(playerId, e);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Propagate native seek failures to the returned future

When the native seek rejects, such as for non-seekable content or an invalid player state, this catch completes an internal completer but then returns normally. The first caller therefore observes a successful seekTo, and queued seeks enter the .then branch and also complete successfully; meanwhile the internal completer's error is unobserved. Rethrow the exception or ensure _startSeek returns the operation's completer future.

Useful? React with 👍 / 👎.

Comment on lines +137 to +140
final _SeekOperation op = _SeekOperation(targetPosition);
_pendingSeeks.putIfAbsent(playerId, () => <_SeekOperation>[]);
_pendingSeeks[playerId]!.add(op);
return op.completer.future;

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 Coalesce pending seeks instead of replaying every position

When several seekTo calls arrive while one is active, every requested position is appended and later issued as a separate native seek. During rapid scrubbing this replays stale intermediate positions before reaching the latest request, causing latency proportional to the number of calls and defeating the intended latest-pending-position behavior. Retain only the newest pending target while preserving completion of all associated futures.

Useful? React with 👍 / 👎.

Comment on lines +201 to +203
final _SeekOperation? op = _activeSeeks.remove(playerId);
if (op != null && !op.completer.isCompleted) {
op.completer.completeError('Player was disposed.');

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 Complete the future actually returned for an active seek

If a player is disposed while its first seek is in flight, this reports cancellation through the active operation's completer, but that future was never returned—the caller received _startSeek's Pigeon future instead. Disposal destroys the native callback, so the caller's future can remain pending indefinitely while this orphaned completeError is emitted as an unhandled asynchronous error.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant