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

Conversation

@bc-lee
Copy link
Contributor

@bc-lee bc-lee commented May 20, 2024

This patch addresses the missing implementation of platformDispatcher.views on Linux. It checks the refresh rate of the renderer's window and returns the value. Without this implementation, WidgetsBinding.instance.platformDispatcher.views.first.display.size would throw an exception on Linux, preventing safe usage.

Related: flutter/flutter#144230

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 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.

This patch addresses the missing implementation of
`platformDispatcher.views` on Linux. It checks if the refresh rate of
the primary or first monitor is available and returns the value.
Without this implementation,
`WidgetsBinding.instance.platformDispatcher.views.first.display.size`
would throw an exception on Linux, preventing safe usage.

Related: flutter/flutter#144230
@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 "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

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

@jonahwilliams
Copy link
Contributor

Maybe @robert-ancell has some testing Ideas? It would be great to have this.

Copy link
Contributor

@robert-ancell robert-ancell left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, this should be good with the logic moved to the renderer.

Instead of calculate refresh rate directly in fl_engine.cc, move
the logic to fl_renderer.cc and implement it also in the
headless renderer.
@bc-lee
Copy link
Contributor Author

bc-lee commented May 25, 2024

Thanks for the review.

@bc-lee
Copy link
Contributor Author

bc-lee commented May 26, 2024

The updated code now has a test for the mock render's refresh rate.

I'm not good at using GLib, because I think glib mimics OOP in a hard way. That's why I'm interested in Flutter, which uses a "real OOP" language for UI development. However, to fix engine behavior, I still need to write some GLib code, unfortunately :( Please correct my code if I made a mistake.

Copy link
Contributor

@robert-ancell robert-ancell left a comment

Choose a reason for hiding this comment

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

Looks good with the documentation fix, thanks!

@robert-ancell robert-ancell merged commit 416c619 into flutter:main May 28, 2024
@bc-lee bc-lee deleted the feature/linux-refresh-rate branch May 28, 2024 01:05
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 28, 2024
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.

3 participants