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

[Windows] handle repaint message in FlutterView window #34306

Merged
merged 4 commits into from
Jul 13, 2022

Conversation

sevenstars
Copy link
Contributor

This PR will fix the blank FlutterView issue by handling the reapint message in FlutterView window.

Currently, WM_PAINT msg is not handled in flutter window and the default WindowProc will do nothing but painting the background. In some user cases, e.g., hide/show/min/max the app window, this will cause blank FlutterView described in the following 2 issues, as the framework has no knowledge of it and will not trigger a new frame if the content is static and there are no running animation.

This PR will fix:
flutter/flutter#101339
flutter/flutter#102030

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@cbracken cbracken requested review from cbracken and loic-sharma June 30, 2022 07:11
@cbracken cbracken changed the title [Windows] handle reapint message in FlutterView window [Windows] handle repaint message in FlutterView window Jun 30, 2022
EXPECT_CALL(delegate, OnWindowRepaint()).Times(1);

win32window.InjectWindowMessage(WM_PAINT, 0, 0);
}
Copy link
Member

Choose a reason for hiding this comment

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

The inject window message is really nice! 🏅

Could you also add a test that calls OnPaint directly too since it's a public API?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@sevenstars sevenstars requested a review from loic-sharma July 5, 2022 06:15
@sevenstars sevenstars force-pushed the fix_repaint_on_windows branch from bea521c to f2b441b Compare July 8, 2022 10:32
@sevenstars sevenstars requested a review from loic-sharma July 8, 2022 11:34
Copy link
Member

@loic-sharma loic-sharma left a comment

Choose a reason for hiding this comment

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

LGTM - thanks for fixing this!

@sevenstars
Copy link
Contributor Author

LGTM - thanks for fixing this!

Thanks for the review. After merging this PR, I can add another PR to change the implementation of FlutterWindowsView::ForceRedraw() to ScheduleFrame.

@sevenstars sevenstars requested a review from stuartmorgan July 12, 2022 07:53
Copy link
Contributor

@stuartmorgan stuartmorgan left a comment

Choose a reason for hiding this comment

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

LGTM with comment nit.

@sevenstars sevenstars force-pushed the fix_repaint_on_windows branch from f2b441b to 010591d Compare July 13, 2022 06:17
@sevenstars
Copy link
Contributor Author

Rebased onto latest main branch.

@loic-sharma loic-sharma merged commit 563d3b0 into flutter:main Jul 13, 2022
@loic-sharma
Copy link
Member

Thanks for contributing this fix!

engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 13, 2022
betrevisan pushed a commit to betrevisan/engine that referenced this pull request Jul 15, 2022
This PR will fix the blank FlutterView issue by handling the repaint message in FlutterView window.

Currently, WM_PAINT msg is not handled in flutter window and the default WindowProc will do nothing but paint the background. In some user cases, e.g., hide/show/min/max the app window, this can result in blank FlutterView if the content is static and there are no running animation.

Addresses flutter/flutter#101339
Addresses flutter/flutter#102030
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants