Skip to content

[video_player] Fix layout issue caused by Transform.rotate not affecting space calculation. #8685

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

Merged
merged 14 commits into from
Mar 27, 2025

Conversation

fa0311
Copy link
Contributor

@fa0311 fa0311 commented Feb 24, 2025

This pull request resolves #159724.
The issue occurs because Transform.rotate is used when rotation is not 0. Since Transform does not affect space calculations, this leads to the issues.

This is related to #7846.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@fa0311 fa0311 requested a review from tarrinneal as a code owner February 24, 2025 15:57
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@stuartmorgan-g
Copy link
Contributor

Thanks for the contribution! You’ve checked boxes in the PR checklist above that are not reflected in this PR, so I’m assuming this is a work in progress and am marking it as a Draft. Please review the checklist, updating the PR as appropriate, and when the checklist reflects the state of the PR as posted please feel free to mark it as ready for review.

@stuartmorgan-g stuartmorgan-g marked this pull request as draft February 25, 2025 20:47
@stuartmorgan-g stuartmorgan-g removed the request for review from tarrinneal February 25, 2025 20:47
@fa0311 fa0311 marked this pull request as ready for review February 26, 2025 13:03
@fa0311
Copy link
Contributor Author

fa0311 commented Feb 26, 2025

@stuartmorgan

I have added tests to verify the fix:

  • Updated existing tests to check for RotatedBox instead of Transform.rotate.
  • Added a new test to ensure RotatedBox is not used when rotation is not a multiple of 90.

child: child,
);
Widget build(BuildContext context) {
if (rotation % 90 != 0 || rotation == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is silently ignoring any rotation value that's not a multiple of 90 correct? If there are actually cases where this happens, wouldn't silently ignoring them be even more broken than the current behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stuartmorgan
The rotation value in this context can only be 0, 90, 180, or 270 degrees, as most video formats (such as MP4 and MOV) store rotation metadata in 90-degree increments within the tkhd (Track Header) box.

For example, in the current Flutter ExoPlayer backend, any value outside this range is ignored:

try {
reportedRotationCorrection = RotationDegrees.fromDegrees(rotationCorrection);
} catch (IllegalArgumentException e) {
// Rotation correction other than 0, 90, 180, 270 reported by Format. Because this is
// unexpected we apply no rotation correction.
reportedRotationCorrection = RotationDegrees.ROTATE_0;
rotationCorrection = 0;
}

Since RotatedBox only supports quarter-turn rotations, this shouldn't be an issue. However, if an unexpected rotation value appears, should we fall back to Transform.rotate instead of ignoring it?

Copy link
Contributor

Choose a reason for hiding this comment

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

If the expectation is that it's impossible for this Dart code to receive values that aren't multiples of 90 degrees, that should be expressed via an assert, not a runtime conditional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added an assert to ensure that only multiples of 90 degrees are allowed.

Copy link
Contributor

Choose a reason for hiding this comment

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

The conditional statement should be updated to reflect that change as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated the conditional statement to reflect the assert change

@fa0311 fa0311 requested a review from stuartmorgan-g March 13, 2025 17:15
@@ -1,6 +1,7 @@
## 2.9.4

* Reduces the position update interval from 500ms to 100ms.
* Fix layout issue caused by Transform.rotate not affecting space calculation.
Copy link
Contributor

Choose a reason for hiding this comment

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

Fixes

See the CHANGELOG style guide linked from the PR checklist.

@@ -1,6 +1,7 @@
## 2.9.4
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs a new version bump; the previous one was lost in a merge.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issue has been fixed. A new version bump has been added.

Copy link
Contributor

Choose a reason for hiding this comment

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

return child;
}
if (rotation % 90 != 0) {
throw ArgumentError('Rotation must be a multiple of 90');
Copy link
Contributor

Choose a reason for hiding this comment

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

An argument error should be thrown at the point where it is passed as an argument, which is the constructor on line 884.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issue has been fixed.

@fa0311 fa0311 requested a review from stuartmorgan-g March 20, 2025 17:19
Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

LGTM once the version is fixed.

@@ -1,6 +1,7 @@
## 2.9.4
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@tarrinneal tarrinneal left a comment

Choose a reason for hiding this comment

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

lgtm after pubspec version bump.

engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 2, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 2, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 2, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 2, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 2, 2025
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Apr 2, 2025
flutter/packages@125c117...07496eb

2025-04-02 [email protected] [multicast_dns]
MDnsClient::listen supports onError callback (flutter/packages#8888)
2025-04-02 [email protected] Upgrade tests to
use Xcode 16 and iOS 18 (flutter/packages#8968)
2025-04-01 [email protected] Manual roll Flutter from
1d954f4 to 05b5e79 (225 revisions) (flutter/packages#8960)
2025-04-01 [email protected] Drop deprecated HTML head
meta tags (flutter/packages#8970)
2025-04-01 [email protected] Adjust PR checklist formatter
discussion (flutter/packages#8924)
2025-04-01 [email protected] Update CODEOWNERS username
(flutter/packages#8933)
2025-04-01 [email protected]
[flutter_markdown] Added sizedImageBuilder to Markdown widget
(flutter/packages#6739)
2025-04-01 [email protected] [google_maps_flutter] Skip impl copy
of iOS tests (flutter/packages#8975)
2025-04-01 [email protected] [google_maps_flutter] Skip more
hanging iOS tests (flutter/packages#8967)
2025-04-01 [email protected] [url_launcher] When not fully loaded,
clicking close causes the callback to not be triggered correctly.
(flutter/packages#8582)
2025-04-01 [email protected] [camera_avfoundation] Test utils
and mocks swift migration - part 2 (flutter/packages#8892)
2025-03-31 [email protected] [webview_flutter]
Skip flaky legacy tests on iOS (flutter/packages#8911)
2025-03-31 [email protected] [camera_android] Don't override
default fps range when not recording (flutter/packages#8891)
2025-03-31 [email protected] [google_maps_flutter] Fix
typo and remove duplicitous CHANGELOG entry (flutter/packages#8754)
2025-03-31 [email protected] [extension_gsi] Support the
latest version of googleapis_auth (flutter/packages#8931)
2025-03-31 49699333+dependabot[bot]@users.noreply.github.com
[dependabot]: Bump com.android.tools.build:gradle from 8.0.0 to 8.9.1 in
/packages/pigeon/platform_tests/test_plugin/android
(flutter/packages#8955)
2025-03-31 [email protected] [webview_flutter_wkwebview] Fixes crash
when sending undefined message via javascript channel
(flutter/packages#8776)
2025-03-31 49699333+dependabot[bot]@users.noreply.github.com
[dependabot]: Bump com.android.tools.build:gradle from 8.0.0 to 8.9.1 in
/packages/pigeon/platform_tests/alternate_language_test_plugin/android
(flutter/packages#8946)
2025-03-31 [email protected]
[interactive_media_ads] Fixes `AdEventType`s not triggering on iOS in
release mode (flutter/packages#8918)
2025-03-31 [email protected] [google_maps_flutter] Skip test that
hangs iOS CI (flutter/packages#8958)
2025-03-28 [email protected] Manual roll Flutter from
b16430b to 1d954f4 (114 revisions) (flutter/packages#8922)
2025-03-28 [email protected] [camera_avfoundation] Test utils
and mocks swift migration - part 3 (flutter/packages#8912)
2025-03-27 [email protected] Use a more deterministic way of
waiting for ad widgets to be ready. (flutter/packages#8920)
2025-03-27 [email protected] [camera_avfoundation] Test utils
and mocks swift migration - part 1 (flutter/packages#8890)
2025-03-27 [email protected] [pigeon] correct usage of extended
generics in generator methods (flutter/packages#8910)
2025-03-27 [email protected] [video_player] Fix
layout issue caused by `Transform.rotate` not affecting space
calculation. (flutter/packages#8685)
2025-03-27 [email protected]
[shared_preferences] Fix a late initialized error with the example app
(flutter/packages#8540)
2025-03-26 [email protected] [various] Disable sandbox in Chrome
dart tests (flutter/packages#8909)
2025-03-25 [email protected] [tool] Move changed file detection to
base command class (flutter/packages#8730)
2025-03-25 [email protected] [Camera] Add lens
type information (iOS) (flutter/packages#8723)
2025-03-25 [email protected] [pigeon] kotlin equality methods
(flutter/packages#8887)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md

---------

Co-authored-by: Maurice Parrish <[email protected]>
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Apr 3, 2025
flutter/packages@125c117...07496eb

2025-04-02 [email protected] [multicast_dns]
MDnsClient::listen supports onError callback (flutter/packages#8888)
2025-04-02 [email protected] Upgrade tests to
use Xcode 16 and iOS 18 (flutter/packages#8968)
2025-04-01 [email protected] Manual roll Flutter from
1d954f4 to 05b5e79 (225 revisions) (flutter/packages#8960)
2025-04-01 [email protected] Drop deprecated HTML head
meta tags (flutter/packages#8970)
2025-04-01 [email protected] Adjust PR checklist formatter
discussion (flutter/packages#8924)
2025-04-01 [email protected] Update CODEOWNERS username
(flutter/packages#8933)
2025-04-01 [email protected]
[flutter_markdown] Added sizedImageBuilder to Markdown widget
(flutter/packages#6739)
2025-04-01 [email protected] [google_maps_flutter] Skip impl copy
of iOS tests (flutter/packages#8975)
2025-04-01 [email protected] [google_maps_flutter] Skip more
hanging iOS tests (flutter/packages#8967)
2025-04-01 [email protected] [url_launcher] When not fully loaded,
clicking close causes the callback to not be triggered correctly.
(flutter/packages#8582)
2025-04-01 [email protected] [camera_avfoundation] Test utils
and mocks swift migration - part 2 (flutter/packages#8892)
2025-03-31 [email protected] [webview_flutter]
Skip flaky legacy tests on iOS (flutter/packages#8911)
2025-03-31 [email protected] [camera_android] Don't override
default fps range when not recording (flutter/packages#8891)
2025-03-31 [email protected] [google_maps_flutter] Fix
typo and remove duplicitous CHANGELOG entry (flutter/packages#8754)
2025-03-31 [email protected] [extension_gsi] Support the
latest version of googleapis_auth (flutter/packages#8931)
2025-03-31 49699333+dependabot[bot]@users.noreply.github.com
[dependabot]: Bump com.android.tools.build:gradle from 8.0.0 to 8.9.1 in
/packages/pigeon/platform_tests/test_plugin/android
(flutter/packages#8955)
2025-03-31 [email protected] [webview_flutter_wkwebview] Fixes crash
when sending undefined message via javascript channel
(flutter/packages#8776)
2025-03-31 49699333+dependabot[bot]@users.noreply.github.com
[dependabot]: Bump com.android.tools.build:gradle from 8.0.0 to 8.9.1 in
/packages/pigeon/platform_tests/alternate_language_test_plugin/android
(flutter/packages#8946)
2025-03-31 [email protected]
[interactive_media_ads] Fixes `AdEventType`s not triggering on iOS in
release mode (flutter/packages#8918)
2025-03-31 [email protected] [google_maps_flutter] Skip test that
hangs iOS CI (flutter/packages#8958)
2025-03-28 [email protected] Manual roll Flutter from
b16430b to 1d954f4 (114 revisions) (flutter/packages#8922)
2025-03-28 [email protected] [camera_avfoundation] Test utils
and mocks swift migration - part 3 (flutter/packages#8912)
2025-03-27 [email protected] Use a more deterministic way of
waiting for ad widgets to be ready. (flutter/packages#8920)
2025-03-27 [email protected] [camera_avfoundation] Test utils
and mocks swift migration - part 1 (flutter/packages#8890)
2025-03-27 [email protected] [pigeon] correct usage of extended
generics in generator methods (flutter/packages#8910)
2025-03-27 [email protected] [video_player] Fix
layout issue caused by `Transform.rotate` not affecting space
calculation. (flutter/packages#8685)
2025-03-27 [email protected]
[shared_preferences] Fix a late initialized error with the example app
(flutter/packages#8540)
2025-03-26 [email protected] [various] Disable sandbox in Chrome
dart tests (flutter/packages#8909)
2025-03-25 [email protected] [tool] Move changed file detection to
base command class (flutter/packages#8730)
2025-03-25 [email protected] [Camera] Add lens
type information (iOS) (flutter/packages#8723)
2025-03-25 [email protected] [pigeon] kotlin equality methods
(flutter/packages#8887)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md

---------

Co-authored-by: Maurice Parrish <[email protected]>
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 3, 2025
marvin-kolja added a commit to marvin-kolja/packages that referenced this pull request May 4, 2025
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 p: video_player
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[video_player_android] Flutter player widget does not scale correctly if video uses rotation correction
3 participants