-
Notifications
You must be signed in to change notification settings - Fork 505
add new property DisplayInfo.RefreshRate #1505
add new property DisplayInfo.RefreshRate #1505
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking really good. We just can't break API.
affa970
to
0994f1f
Compare
* with a proper implementation on Android and iOS * MacOS and UWP always give a rate of zero
0994f1f
to
46a0f8b
Compare
Based on xamarin-macios issue: xamarin/xamarin-macios#9958 Copied code from: https://gist.github.com/chamons/1eae64a2e5e10cbaf18b140e92ec4ca3
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested on my Razer Phone and got that sweet extra Hz
CI seems unhappy on some devices. Can't seem to repro it locally :( |
using var display = GetDefaultDisplay(); | ||
var display = GetDefaultDisplay(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this, it appears that Android 21-24 throws a ObjectDisposedException for the Display object
Cool :) |
Thanks a lot for adding a MacOS implementation, @mattleibow! I just ran Samples.Mac on a MacBook with Big Sur, but unfortunately I see a Refresh Rate of zero :/ |
I got 60 on my Mac mini. I saw in the docs that sometimes it will be 0, but let me see if there is more info or another way. Docs: https://developer.apple.com/documentation/coregraphics/1454661-cgdisplaymodegetrefreshrate Not sure if this is the best now that you say it isn't working... |
@janusw I think I may have found a solution... But it doesn't work for my screen... I saw this issue: glfw/glfw#137 Maybe if you tweak some things it works for you? |
Thanks for your efforts here, Matt! I tried your solution, but I still only get a RefreshRate of 0 on the MacBook. I see |
This is not the most correct way, but is probably good enough. If there are any better ways in future, we can just add them in or replace this logic.
Awesome! Thanks for merging 😃 |
* main: Update docs Add new property DisplayInfo.RefreshRate (xamarin#1505)
Description of Change
This enhancement was proposed in #1443. It extends the
DisplayInfo
class with information about the display's refresh rate.The new property has an implementation on Android, iOS and UWP. On MacOS it is always zero at present, because the corresponding Xamarin API is missing on MacOS (see also xamarin/xamarin-macios#9958).
I have tested the implementation on real hardware with Android 10 and iOS14.
Bugs Fixed
API Changes
List all API changes here (or just put None), example:
Added:
public float DisplayInfo.RefreshRate { get; }
DisplayInfo(double width, double height, double density, DisplayOrientation orientation, DisplayRotation rotation, float rate)
Behavioral Changes
None.
PR Checklist
main
at time of PR