Skip to content
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

fix: Offset text regions that are out of viewport #6986

Merged
merged 2 commits into from
Jul 8, 2024

Conversation

avelad
Copy link
Member

@avelad avelad commented Jul 4, 2024

Fixes #3732 (we resolve it using offset operation instead of clipping)

@avelad avelad added type: bug Something isn't working correctly component: captions/subtitles The issue involves captions or subtitles priority: P2 Smaller impact or easy workaround labels Jul 4, 2024
@avelad avelad added this to the v4.11 milestone Jul 4, 2024
@avelad avelad force-pushed the UITextDisplayer-clip-regions branch from 0da4587 to 0ac98d8 Compare July 4, 2024 13:03
@shaka-bot
Copy link
Collaborator

Incremental code coverage: 95.00%

@avelad avelad force-pushed the UITextDisplayer-clip-regions branch from 0ac98d8 to 349aac1 Compare July 4, 2024 14:59
@avelad avelad requested review from littlespex and theodab July 5, 2024 06:21
@@ -504,6 +508,19 @@ shaka.text.UITextDisplayer = class {
regionElement.style.left = region.viewportAnchorX -
region.regionAnchorX * region.width / 100 + viewportAnchorUnit;
Copy link
Contributor

Choose a reason for hiding this comment

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

while the below is probably fine, in trying to figure out what was going on I realized that this and section uses region.height/width but doesn't account for whether it's in line units of precentages. This ends up working out for left, but for top we end up with 95% but it should be 77.68%, which is what we'd get if we multiply the height by the then lineHeightMultiple. We potentially should store the calculated height and width from above in a var so that we can use it here and below, if we wanted to keep that. Though, potentially shouldn't be necessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

@gkatsev Can you create a PR with it? Thanks!

@@ -504,6 +508,19 @@ shaka.text.UITextDisplayer = class {
regionElement.style.left = region.viewportAnchorX -
region.regionAnchorX * region.width / 100 + viewportAnchorUnit;
}
if (region.heightUnits !== pixelUnit &&
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't get why you are checking, for these things, !== pixelUnit, instead of checking === percentageUnit.
That would suggest that this code works for both percentages and lines.
This code assumes that the max for width and height are both 100, which is true for percentages, but lines max out at 16 or 32 depending on the aspect ratio.

Copy link
Member Author

Choose a reason for hiding this comment

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

Internally we convert the lines to % that's why I don't check percentages

lib/text/ui_text_displayer.js Show resolved Hide resolved
lib/text/ui_text_displayer.js Outdated Show resolved Hide resolved
@avelad avelad changed the title fix: UITextDisplayer doesn't clip regions to video fix: Offset text regions that are out of viewport Jul 8, 2024
@avelad avelad requested a review from theodab July 8, 2024 08:21
@avelad avelad merged commit ca7fd6e into shaka-project:main Jul 8, 2024
10 of 18 checks passed
@avelad avelad deleted the UITextDisplayer-clip-regions branch July 8, 2024 08:50
avelad added a commit that referenced this pull request Jul 8, 2024
Fixes #3732 (we
resolve it using offset operation instead of clipping)
avelad added a commit that referenced this pull request Jul 8, 2024
Fixes #3732 (we
resolve it using offset operation instead of clipping)
@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Sep 6, 2024
@shaka-project shaka-project locked as resolved and limited conversation to collaborators Sep 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
component: captions/subtitles The issue involves captions or subtitles priority: P2 Smaller impact or easy workaround status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UITextDisplayer doesn't clip regions to video
4 participants