Skip to content

Fix UIController not keeping the player at the video's aspect ratio - #140

Merged
MattiasBuelens merged 2 commits into
developfrom
bugfix/constrained-aspect-ratio
Oct 20, 2026
Merged

MattiasBuelens merged 2 commits into
developfrom
bugfix/constrained-aspect-ratio

Conversation

@MattiasBuelens

Copy link
Copy Markdown
Collaborator

Summary

  • Modifier.constrainedAspectRatio has had no effect since v1.4.0 (ef51a33, "Optimize Modifier.constrainedAspectRatio"). ConstrainedAspectRatioNode implemented the legacy LayoutModifier interface instead of LayoutModifierNode, and Compose only registers a Modifier.Node as a layout node if it implements LayoutModifierNode (see calculateNodeKindSetFrom(node: Modifier.Node)). So measure() was never called and the modifier passed sizes through unchanged.
  • Effect: UIController and DefaultUI (mobile) didn't keep the player at the video's aspect ratio, or at 16:9 before the video size is known. They filled whatever space the parent gave them. The TV UI doesn't use this modifier.
  • Fix: implement LayoutModifierNode. The measure and intrinsic overrides have the same signatures, so nothing else changes.
  • This also clears the two lint warnings on ConstrainedAspectRatioElement.create() (ModifierFactoryExtensionFunction, ModifierFactoryReturnType). Lint was treating create() as a modifier factory because the node was a Modifier type through LayoutModifier.

Test plan

  • New ConstrainedAspectRatioTest (6 tests): height derived from a fixed width, from a square ratio and from fillMaxWidth(); width derived from a fixed height; incoming constraints are never violated; a real UIController in a 320 × 1000 dp box measures 320 × 180 dp
  • 5 of the 6 tests fail without the fix (for example, UIController measures 320 × 1000 dp). The constraints test passes either way, because the fixed size passes straight through.
  • ./gradlew :ui:testDebugUnitTest
  • ./gradlew :ui:lintDebug: no issues found

Generated with Devin

MattiasBuelens and others added 2 commits October 20, 2026 12:06
ConstrainedAspectRatioNode implemented the legacy LayoutModifier interface
instead of LayoutModifierNode. Compose only treats a Modifier.Node as a
layout node if it implements LayoutModifierNode, so measure() was never
called and UIController didn't keep the player at the video's aspect ratio.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@MattiasBuelens
MattiasBuelens force-pushed the bugfix/constrained-aspect-ratio branch from c1c0e17 to ac19d90 Compare October 20, 2026 10:09
@MattiasBuelens MattiasBuelens added the bug Something isn't working label Oct 20, 2026
@MattiasBuelens
MattiasBuelens merged commit a779192 into develop Oct 20, 2026
1 check passed
@MattiasBuelens
MattiasBuelens deleted the bugfix/constrained-aspect-ratio branch October 20, 2026 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant