Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

WIP: Smooth window resizing on macOS #21110

Closed
wants to merge 2 commits into from

Conversation

knopp
Copy link
Member

@knopp knopp commented Sep 11, 2020

Description

Make window resizing on macOS smooth, responsive and synchronous with windows size.

Related design doc: https://flutter.dev/go/desktop-resize-macos

Depends on: #21108

Related Issues

flutter/flutter#44136

Tests

I added the following tests:

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the contributor guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the C++, Objective-C, Java style guides for the engine.
  • I read the tree hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation.
  • All existing and new tests are passing.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read handling breaking changes.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@iskakaushik iskakaushik self-requested a review September 14, 2020 16:49
Copy link
Contributor

@iskakaushik iskakaushik left a comment

Choose a reason for hiding this comment

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

initial review, need to take a deeper look still. Have you thought about a testing strategy for this change?

@@ -262,7 +261,7 @@ - (BOOL)runWithEntrypoint:(NSString*)entrypoint {
const FlutterCustomTaskRunners custom_task_runners = {
.struct_size = sizeof(FlutterCustomTaskRunners),
.platform_task_runner = &cocoa_task_runner_description,
.render_task_runner = &cocoa_task_runner_description,
.render_task_runner = nullptr,
Copy link
Contributor

Choose a reason for hiding this comment

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

this line can be removed.

@@ -79,7 +80,9 @@ source_set("flutter_framework_source") {

libs = [
"Cocoa.framework",
"QuartzCore.framework",
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: arrange these in alphabetical order.

-self.layer.bounds.size.height, 0);
contentLayer.frame = self.layer.bounds;

[contentLayer setContents:nil];
Copy link
Contributor

Choose a reason for hiding this comment

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

add a comment explaining why we need to set to nil before setting it to the contents of the ioSurface

@@ -26,6 +26,11 @@
*/
- (void)updateWindowMetrics;

/**
* Schedules the block on rater thread.
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: rater -> raster

void* copy = Block_copy((__bridge void*)block);
FlutterEnginePostRenderThreadTask(
_engine,
[](void* cb) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: rename to callback

@@ -334,6 +337,18 @@ - (void)updateWindowMetrics {
FlutterEngineSendWindowMetricsEvent(_engine, &event);
}

- (void)scheduleOnRasterTread:(dispatch_block_t)block {
void* copy = Block_copy((__bridge void*)block);
Copy link
Contributor

Choose a reason for hiding this comment

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

curious, why do we need to copy the block here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Blocks are by default allocated on stack. It needs to be moved to heap otherwise it will get destroyed on scope exit.

@@ -280,7 +279,8 @@ - (BOOL)runWithEntrypoint:(NSString*)entrypoint {
}

[self sendUserLocales];
[self updateWindowMetrics];

[self.viewController.flutterView start];
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason to have start rather than doing it in init or ctor for FlutterView?

Copy link
Member Author

Choose a reason for hiding this comment

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

IIRC start causes flutterView to drive viewport size change. I think I'd prefer that to be separate method rather than doing it from constructor.

@@ -7,32 +7,39 @@
/**
* Listener for view resizing.
Copy link
Contributor

Choose a reason for hiding this comment

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

fix the doc.

@knopp knopp mentioned this pull request Sep 17, 2020
12 tasks
@knopp
Copy link
Member Author

knopp commented Sep 17, 2020

Superseded by #21252

@knopp knopp closed this Sep 17, 2020
@knopp knopp deleted the macos_smooth_resizing_wip_pr branch July 17, 2021 09:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants