Repository navigation
Fix UIController not keeping the player at the video's aspect ratio - #140
Merged
Merged
Conversation
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
force-pushed
the
bugfix/constrained-aspect-ratio
branch
from
October 20, 2026 10:09
c1c0e17 to
ac19d90
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Modifier.constrainedAspectRatiohas had no effect since v1.4.0 (ef51a33, "Optimize Modifier.constrainedAspectRatio").ConstrainedAspectRatioNodeimplemented the legacyLayoutModifierinterface instead ofLayoutModifierNode, and Compose only registers aModifier.Nodeas a layout node if it implementsLayoutModifierNode(seecalculateNodeKindSetFrom(node: Modifier.Node)). Someasure()was never called and the modifier passed sizes through unchanged.UIControllerandDefaultUI(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.LayoutModifierNode. The measure and intrinsic overrides have the same signatures, so nothing else changes.ConstrainedAspectRatioElement.create()(ModifierFactoryExtensionFunction,ModifierFactoryReturnType). Lint was treatingcreate()as a modifier factory because the node was aModifiertype throughLayoutModifier.Test plan
ConstrainedAspectRatioTest(6 tests): height derived from a fixed width, from a square ratio and fromfillMaxWidth(); width derived from a fixed height; incoming constraints are never violated; a realUIControllerin a 320 × 1000 dp box measures 320 × 180 dpUIControllermeasures 320 × 1000 dp). The constraints test passes either way, because the fixed size passes straight through../gradlew :ui:testDebugUnitTest./gradlew :ui:lintDebug: no issues foundGenerated with Devin