Skip to content

perf(legacy): skip the native bounds read when setBounds gets a full Rect - #607

Open
palmoni5 wants to merge 1 commit into
leanflutter:mainfrom
palmoni5:upstream/legacy-setbounds-full-rect
Open

palmoni5 wants to merge 1 commit into
leanflutter:mainfrom
palmoni5:upstream/legacy-setbounds-full-rect

Conversation

@palmoni5

Copy link
Copy Markdown

Problem

WindowManager.setBounds in the 0.5.x-compatible legacy API always read the window's current bounds through nativeapi (a synchronous FFI call) before applying new ones. It did this even when the caller passed a full Rect, so none of the values it read were used. Apps that restore or move the window with a full Rect pay for that extra native round trip on every call.

Change

Tests

New test/legacy_set_bounds_test.dart, with its own fake nativeapi.Window that counts bounds reads. It checks that:

  • a full Rect is applied with no bounds read;
  • position-only and size-only updates still read the omitted values;
  • a full Rect wins over position/size;
  • animate: true falls back to a plain set;
  • an empty request does nothing.

dart format, flutter analyze (package and example) and flutter test all pass locally.

…Rect

setBounds read the window's current bounds through nativeapi before every
call, even when the caller passed a full Rect and none of the current values
were used. Only read them when position or size is partial.

Adds debugBindWindow (same hook as the sibling legacy PRs) so the bridge can
be tested against a Dart fake window.
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.

1 participant