Skip to content

fix: Improve viewport resizing behavior (backport of #2170)#2233

Closed
thevaadinman wants to merge 3 commits into
vaadin:5.4from
thevaadinman:fix-viewport-resize
Closed

fix: Improve viewport resizing behavior (backport of #2170)#2233
thevaadinman wants to merge 3 commits into
vaadin:5.4from
thevaadinman:fix-viewport-resize

Conversation

@thevaadinman
Copy link
Copy Markdown
Contributor

Original description:

The fix replaces the single-shot adjustment with a converging retry loop. The browser chrome (title bar, borders) is constant for a session. Iteration 1 discovers the offset, iteration 2 (or rarely 3) nails the target. 5 attempts is generous safety margin for unusual environments (remote grids, DPI scaling).

Removes hardcoded Mac FF offsets that are irrelevant for modern browsers and cause unnecessary overshoot on other platforms (extrah=106, extraw=0) — starts with the desired dimensions directly

Loops up to 5 times, each iteration measuring the actual viewport via JS, computing the diff, and adjusting the window size using the current window size (not accumulated offsets)

Returns early as soon as the viewport matches the target

Re-throws UnsupportedOperationException without wrapping, while wrapping other exceptions

Logs each adjustment at debug level for troubleshooting

Fixes: [#2167]

Original description:

The fix replaces the single-shot adjustment with a converging retry loop. The browser chrome (title bar, borders) is constant for a session. Iteration 1 discovers the offset, iteration 2 (or rarely 3) nails the target. 5 attempts is generous safety margin for unusual environments (remote grids, DPI scaling).

Removes hardcoded Mac FF offsets that are irrelevant for modern browsers and cause unnecessary overshoot on other platforms (extrah=106, extraw=0) — starts with the desired dimensions directly
Loops up to 5 times, each iteration measuring the actual viewport via JS, computing the diff, and adjusting the window size using the current window size (not accumulated offsets)
Returns early as soon as the viewport matches the target
Re-throws UnsupportedOperationException without wrapping, while wrapping other exceptions
Logs each adjustment at debug level for troubleshooting
Fixes: vaadin#2167
@thevaadinman
Copy link
Copy Markdown
Contributor Author

Test failures are unrelated to this patch.. the test failures are due to the versions of various testing librarires that TestBench 5.4 uses being incompatible with Java 21+, which GitHub Actions uses. This was not an issue with the old CI setup that ran on TeamCity since we had it configured to build on a Java 8 JDK.
This PR is not the correct place to fix those test failures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants