Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Linux platform support for fetching refresh rate on startup. #52934

Merged
merged 7 commits into from
May 28, 2024

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
Member

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.

shell/platform/linux/fl_engine.cc Outdated Show resolved Hide resolved
shell/platform/linux/fl_engine.cc Outdated Show resolved Hide resolved
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
26 checks passed
@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
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request May 28, 2024
…149148)

flutter/engine@cf201b1...416c619

2024-05-28 [email protected] Add Linux platform support for fetching refresh rate on startup. (flutter/engine#52934)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/ doc/main/autoroll/README.md
victorsanni pushed a commit to victorsanni/flutter that referenced this pull request May 31, 2024
…lutter#149148)

flutter/engine@cf201b1...416c619

2024-05-28 [email protected] Add Linux platform support for fetching refresh rate on startup. (flutter/engine#52934)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/ doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants