Skip to content

[video_player] Convert event channel to Swift and Pigeon - #13375

Merged
auto-submit[bot] merged 19 commits into
flutter:mainfrom
stuartmorgan:video-player-ios-swift-event-channel
Nov 13, 2026
Merged

auto-submit[bot] merged 19 commits into
flutter:mainfrom
stuartmorgan:video-player-ios-swift-event-channel

Conversation

@stuartmorgan

@stuartmorgan stuartmorgan commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Converts FVPVideoEventListener and the FVPEventBridge implementation from Obj-C to Swift, and now that it uses Swift, adopts Pigeon's Swift event channel support to eliminate the use of stringly-typed data.

The overhauled Dart unit test code is taken directly from the rewrite that I did previously for video_player_android's Kotlin Pigeon event channel conversion, with minimal changes to match the iOS test cases.

Also includes a minor adjustment to video_player_android to add missing unregistration code to avoid a minor native object leak, matching changes made on the iOS side during review. This requires a Pigeon update to pick up the functionality needed to unregister.

Part of flutter/flutter#119105

Pre-Review Checklist

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request converts the internal event channel implementation of the AVFoundation video player plugin to Swift using Pigeon, replacing the Objective-C FVPEventBridge with a Swift EventBridge class and introducing structured event classes. Feedback on the changes highlights a potential memory leak where the EventBridge is registered as a stream handler but never unregistered upon disposal, creating a strong retain cycle. Suggestions are provided to store references to the messenger and channel suffix to properly unregister the stream handler when the player is disposed.

@jmagman jmagman added the CICD Run CI/CD label Oct 22, 2026
@stuartmorgan
stuartmorgan marked this pull request as draft October 24, 2026 22:54
@stuartmorgan
stuartmorgan force-pushed the video-player-ios-swift-event-channel branch from f5f60d8 to cd29985 Compare October 24, 2026 22:56
@stuartmorgan

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request transitions the event channel implementation of the video_player_avfoundation package from Objective-C to Swift using Pigeon's event channel generation, and updates video_player_android to handle event channel unregistration upon player disposal. A misplaced and duplicate changelog entry for version 2.12.3 was identified at the bottom of the AVFoundation CHANGELOG.md file and should be removed.

@stuartmorgan
stuartmorgan marked this pull request as ready for review October 30, 2026 15:13
@stuartmorgan

Copy link
Copy Markdown
Contributor Author

@jmagman I folded the Android unregistration change into this PR since I was making the same change on the iOS side as part of updating this PR; let me know if you'd prefer I split that into a separate PR.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request updates the video_player_android and video_player_avfoundation packages to utilize Pigeon-generated event channels for video events. In video_player_android, the event channel is now properly cleaned up on player disposal to prevent native object leaks. In video_player_avfoundation, the internal event channel implementation is migrated from Objective-C to Swift. Feedback recommends marking the conforming test stub StubEventListener with @MainActor to maintain consistent actor isolation with the VideoEventListener protocol.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@stuartmorgan
stuartmorgan requested a review from jmagman November 8, 2026 23:34
Comment on lines +52 to +53
if let queuedEvents = queuedEvents {
for event in queuedEvents {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor nit, the queuedEvents shadow is a bit weird, could do something like:

queuedEvents?.forEach { event in

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That gives an analysis warning (ReplaceForEachWithForLoop). But I recently learned that we've reaching a minimum Xcode version where we can now safely use the if let foo shorthand instead of the old, weirder-looking standard of if let foo = foo, so I shortened it here (and throughout the plugin where I had been using the older form while converting).

public void dispose() {
isWaitingForValidDuration = false;
mainHandler.removeCallbacks(initializationFallback);
events.onDisposed();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Did you add a test for this new leak fix?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I had forgotten, but now I have 🙂 I don't think there's a way to directly test for the leak itself in Java, but I now test that it unregisters (via a mock).

@jmagman jmagman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM with minor nits

@stuartmorgan stuartmorgan added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 13, 2026
@auto-submit
auto-submit Bot merged commit c8b7e7b into flutter:main Nov 13, 2026
13 checks passed
LouiseHsu pushed a commit to LouiseHsu/flutter that referenced this pull request Nov 13, 2026
…lutter#196558)

Manually rolls flutter/packages from 14f9933a8cd6 to 015df97cbc3f (5
revisions). This is the same one-line change the [flutter/packages →
flutter/flutter
autoroller](https://autoroll.skia.org/r/flutter-packages-flutter-autoroll)
makes.

Today's two automatic rolls, flutter#196527 and flutter#196547, failed on presubmit
jobs that don't use the packages pin (`Windows tool_integration_tests_5`
and `Linux_android_emu android_engine_opengles_tests`). The roller
closed the second one after its roll window ended. It only rolls on
weekdays and doesn't support manual rolls, so its next roll would be on
Monday.

flutter/packages@14f9933...015df97

2026-11-13 [camera_windows] Fall back to temp dir for capture path.
(flutter/packages#12755)
2026-11-13 [video_player] Convert event channel to Swift and Pigeon
(flutter/packages#13375)
2026-11-13 [material_ui] Document and demonstrate safe MaterialBanner
dismissal across routes (flutter/packages#13267)
2026-11-12 [flutter_svg] Add a byte budget for the compiled SVG cache
(flutter/packages#13596)
2026-11-12 Roll Flutter from b98afb5 to 9c427b5 (29 revisions)
(flutter/packages#13636)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD p: video_player platform-android platform-ios platform-macos

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants