-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[video_player] Make sure the plugin is correctly initialized #2434
Conversation
|
@cyanglaz can I ask you for a review and a tip on how to properly test this? |
|
Added a test to check if init has been called. |
|
@mklim do you have an idea why the test works locally but fails on Cirrus CI? Is there maybe a better way to test this? |
Yes, static initializers are lazily evaluated when the field is first used. |
amirh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| final VideoPlayerPlatform _videoPlayerPlatform = VideoPlayerPlatform.instance | ||
| // This will clear all open videos on the platform when a full restart is | ||
| // performed. | ||
| ..init(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this hack in general, but we don't have a better alternative right now. I filed flutter/flutter#48586 to expose an engine restart hook to the plugin's platform code.
amirh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to fix the unit test before landing
f6067c5 to
5937282
Compare
5937282 to
5647dbd
Compare
packages/video_player/video_player/test/video_player_initialization_test.dart
Show resolved
Hide resolved
|
@amirh does this need to be reviewed by another person? |
|
I was just waiting for the tree to become green before landing (was red for multiple days until now 😞 ) |
|
Oh ok. Thanks for merging! |
…#2434) The initialization was done through a static initialization of an unused field, and since static initialization is invoked lazily it was never initialized.
…#2434) The initialization was done through a static initialization of an unused field, and since static initialization is invoked lazily it was never initialized.
…#2434) The initialization was done through a static initialization of an unused field, and since static initialization is invoked lazily it was never initialized.
Description
This seemed to have no effect. Was it optimized away because
_was not used?Related Issues
Fixes flutter/flutter#47524
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?