diff mbox series

[PATCH-for-9.2] ui/cocoa: Temporarily ignore annoying deprecated declaration warnings

Message ID 20241121131954.98949-1-philmd@linaro.org
State Superseded
Headers show
Series [PATCH-for-9.2] ui/cocoa: Temporarily ignore annoying deprecated declaration warnings | expand

Commit Message

Philippe Mathieu-Daudé Nov. 21, 2024, 1:19 p.m. UTC
These warnings are breaking some build configurations since 2 months
now (https://gitlab.com/qemu-project/qemu/-/issues/2575):

  ui/cocoa.m:662:14: error: 'CVDisplayLinkCreateWithCGDisplay' is deprecated: first deprecated in macOS 15.0 - use NSView.displayLink(target:selector:), NSWindow.displayLink(target:selector:), or NSScreen.displayLink(target:selector:)  [-Werror,-Wdeprecated-declarations]
    662 |         if (!CVDisplayLinkCreateWithCGDisplay(display, &displayLink)) {
        |              ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreVideo.framework/Headers/CVDisplayLink.h:89:20: note: 'CVDisplayLinkCreateWithCGDisplay' has been explicitly marked deprecated here
     89 | CV_EXPORT CVReturn CVDisplayLinkCreateWithCGDisplay(
        |                    ^
  ui/cocoa.m:663:29: error: 'CVDisplayLinkGetNominalOutputVideoRefreshPeriod' is deprecated: first deprecated in macOS 15.0 - use NSView.displayLink(target:selector:), NSWindow.displayLink(target:selector:), or NSScreen.displayLink(target:selector:)  [-Werror,-Wdeprecated-declarations]
    663 |             CVTime period = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(displayLink);
        |                             ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreVideo.framework/Headers/CVDisplayLink.h:182:18: note: 'CVDisplayLinkGetNominalOutputVideoRefreshPeriod' has been explicitly marked deprecated here
    182 | CV_EXPORT CVTime CVDisplayLinkGetNominalOutputVideoRefreshPeriod( CVDisplayLinkRef CV_NONNULL displayLink );
        |                  ^
  ui/cocoa.m:664:13: error: 'CVDisplayLinkRelease' is deprecated: first deprecated in macOS 15.0 - use NSView.displayLink(target:selector:), NSWindow.displayLink(target:selector:), or NSScreen.displayLink(target:selector:)  [-Werror,-Wdeprecated-declarations]
    664 |             CVDisplayLinkRelease(displayLink);
        |             ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreVideo.framework/Headers/CVDisplayLink.h:249:16: note: 'CVDisplayLinkRelease' has been explicitly marked deprecated here
    249 | CV_EXPORT void CVDisplayLinkRelease( CV_RELEASES_ARGUMENT CVDisplayLinkRef CV_NULLABLE displayLink );
        |                ^
  3 errors generated.

For the next release, ignore the warnings using #pragma directives.
At least until we figure the correct new API usage.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 ui/cocoa.m | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Phil Dennis-Jordan Nov. 21, 2024, 2:35 p.m. UTC | #1
As we're talking about macOS-only code I'd perhaps have used '#pragma clang
diagnostic' rather than the GCC versions, but clang seems to understand
these just fine too. (Plus, we very much intend for these to be genuinely
temporary.)

Reviewed-by: Phil Dennis-Jordan <phil@philjordan.eu>
Tested-by: Phil Dennis-Jordan <phil@philjordan.eu>

I'll try to find some spare cycles to come up with a clean solution to the
deprecation issue towards the end of the year. I need to research the
available alternative APIs for another project anyway.

I think part of the reason for the deprecation is that most modern Macs (as
with other modern laptop and desktop computers) actually use a variable
display frame rate, so the concept of a "native" frame rate is no longer
well-defined. In an ideal world the frame rate would be something that's
negotiable between the host UI and the virtual hardware.

For example, the macOS PV Graphics I've been working on integrating would
actually prefer a "push" arrangement where the guest/PV hardware notify the
host when the next frame is ready, rather than expecting a fixed-rate frame
refresh interrupt or similar. So when using that there would actually not
be any need for the display-linked timer at all if the UI is happy with the
hw calling dpy_gfx_update_full()/graphic_hw_update_done() proactively
whenever it has a new frame available. I'm not sure what the story is for
other display adapters in QEMU, but I can do a survey of that.


On Thu, 21 Nov 2024 at 14:20, Philippe Mathieu-Daudé <philmd@linaro.org>
wrote:

> These warnings are breaking some build configurations since 2 months
> now (https://gitlab.com/qemu-project/qemu/-/issues/2575):
>
>   ui/cocoa.m:662:14: error: 'CVDisplayLinkCreateWithCGDisplay' is
> deprecated: first deprecated in macOS 15.0 - use
> NSView.displayLink(target:selector:),
> NSWindow.displayLink(target:selector:), or
> NSScreen.displayLink(target:selector:)  [-Werror,-Wdeprecated-declarations]
>     662 |         if (!CVDisplayLinkCreateWithCGDisplay(display,
> &displayLink)) {
>         |              ^
>
> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreVideo.framework/Headers/CVDisplayLink.h:89:20:
> note: 'CVDisplayLinkCreateWithCGDisplay' has been explicitly marked
> deprecated here
>      89 | CV_EXPORT CVReturn CVDisplayLinkCreateWithCGDisplay(
>         |                    ^
>   ui/cocoa.m:663:29: error:
> 'CVDisplayLinkGetNominalOutputVideoRefreshPeriod' is deprecated: first
> deprecated in macOS 15.0 - use NSView.displayLink(target:selector:),
> NSWindow.displayLink(target:selector:), or
> NSScreen.displayLink(target:selector:)  [-Werror,-Wdeprecated-declarations]
>     663 |             CVTime period =
> CVDisplayLinkGetNominalOutputVideoRefreshPeriod(displayLink);
>         |                             ^
>
> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreVideo.framework/Headers/CVDisplayLink.h:182:18:
> note: 'CVDisplayLinkGetNominalOutputVideoRefreshPeriod' has been explicitly
> marked deprecated here
>     182 | CV_EXPORT CVTime
> CVDisplayLinkGetNominalOutputVideoRefreshPeriod( CVDisplayLinkRef
> CV_NONNULL displayLink );
>         |                  ^
>   ui/cocoa.m:664:13: error: 'CVDisplayLinkRelease' is deprecated: first
> deprecated in macOS 15.0 - use NSView.displayLink(target:selector:),
> NSWindow.displayLink(target:selector:), or
> NSScreen.displayLink(target:selector:)  [-Werror,-Wdeprecated-declarations]
>     664 |             CVDisplayLinkRelease(displayLink);
>         |             ^
>
> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreVideo.framework/Headers/CVDisplayLink.h:249:16:
> note: 'CVDisplayLinkRelease' has been explicitly marked deprecated here
>     249 | CV_EXPORT void CVDisplayLinkRelease( CV_RELEASES_ARGUMENT
> CVDisplayLinkRef CV_NULLABLE displayLink );
>         |                ^
>   3 errors generated.
>
> For the next release, ignore the warnings using #pragma directives.
> At least until we figure the correct new API usage.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  ui/cocoa.m | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/ui/cocoa.m b/ui/cocoa.m
> index 4c2dd33532..0422dafde4 100644
> --- a/ui/cocoa.m
> +++ b/ui/cocoa.m
> @@ -639,6 +639,9 @@ - (void) updateBounds
>      [self setBoundsSize:NSMakeSize(screen.width, screen.height)];
>  }
>
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
> +
>  - (void) updateUIInfoLocked
>  {
>      /* Must be called with the BQL, i.e. via updateUIInfo */
> @@ -685,6 +688,8 @@ - (void) updateUIInfoLocked
>      dpy_set_ui_info(dcl.con, &info, TRUE);
>  }
>
> +#pragma GCC diagnostic pop
> +
>  - (void) updateUIInfo
>  {
>      if (!allow_events) {
> --
> 2.45.2
>
>
>
Akihiko Odaki Nov. 27, 2024, 7:07 a.m. UTC | #2
On 2024/11/21 23:35, Phil Dennis-Jordan wrote:
> As we're talking about macOS-only code I'd perhaps have used '#pragma 
> clang diagnostic' rather than the GCC versions, but clang seems to 
> understand these just fine too. (Plus, we very much intend for these to 
> be genuinely temporary.)
> 
> Reviewed-by: Phil Dennis-Jordan <phil@philjordan.eu 
> <mailto:phil@philjordan.eu>>
> Tested-by: Phil Dennis-Jordan <phil@philjordan.eu 
> <mailto:phil@philjordan.eu>>
> 
> I'll try to find some spare cycles to come up with a clean solution to 
> the deprecation issue towards the end of the year. I need to research 
> the available alternative APIs for another project anyway.
> 
> I think part of the reason for the deprecation is that most modern Macs 
> (as with other modern laptop and desktop computers) actually use a 
> variable display frame rate, so the concept of a "native" frame rate is 
> no longer well-defined. In an ideal world the frame rate would be 
> something that's negotiable between the host UI and the virtual hardware.
> 
> For example, the macOS PV Graphics I've been working on integrating 
> would actually prefer a "push" arrangement where the guest/PV hardware 
> notify the host when the next frame is ready, rather than expecting a 
> fixed-rate frame refresh interrupt or similar. So when using that there 
> would actually not be any need for the display-linked timer at all if 
> the UI is happy with the hw calling dpy_gfx_update_full()/ 
> graphic_hw_update_done() proactively whenever it has a new frame 
> available. I'm not sure what the story is for other display adapters in 
> QEMU, but I can do a survey of that.

Regarding dpy_gfx_update_full()/graphic_hw_update_done(), it's probably 
better to stay the "pull" semantics. With the pull semantics, we can 
drop frames when the UI cannot update the output in timely manner 
because it's in the power-saving mode or it's just too busy. Adapting to 
variable refresh rate will be achieved by using a platform's mechanism 
that fires a refresh event at proper timing.

There is also another function we need to care: dpy_set_ui_info(). This 
function updates the "mode" of the emulated display to tell the refresh 
rate to the guest. A mode is expected to be somewhat stable so it cannot 
properly represent the variable refresh rate. A safe option is to expose 
the maximum refresh rate via the mode.
Philippe Mathieu-Daudé Dec. 3, 2024, 3:39 p.m. UTC | #3
On 21/11/24 14:19, Philippe Mathieu-Daudé wrote:
> These warnings are breaking some build configurations since 2 months
> now (https://gitlab.com/qemu-project/qemu/-/issues/2575):
> 
>    ui/cocoa.m:662:14: error: 'CVDisplayLinkCreateWithCGDisplay' is deprecated: first deprecated in macOS 15.0 - use NSView.displayLink(target:selector:), NSWindow.displayLink(target:selector:), or NSScreen.displayLink(target:selector:)  [-Werror,-Wdeprecated-declarations]
>      662 |         if (!CVDisplayLinkCreateWithCGDisplay(display, &displayLink)) {
>          |              ^
>    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreVideo.framework/Headers/CVDisplayLink.h:89:20: note: 'CVDisplayLinkCreateWithCGDisplay' has been explicitly marked deprecated here
>       89 | CV_EXPORT CVReturn CVDisplayLinkCreateWithCGDisplay(
>          |                    ^
>    ui/cocoa.m:663:29: error: 'CVDisplayLinkGetNominalOutputVideoRefreshPeriod' is deprecated: first deprecated in macOS 15.0 - use NSView.displayLink(target:selector:), NSWindow.displayLink(target:selector:), or NSScreen.displayLink(target:selector:)  [-Werror,-Wdeprecated-declarations]
>      663 |             CVTime period = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(displayLink);
>          |                             ^
>    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreVideo.framework/Headers/CVDisplayLink.h:182:18: note: 'CVDisplayLinkGetNominalOutputVideoRefreshPeriod' has been explicitly marked deprecated here
>      182 | CV_EXPORT CVTime CVDisplayLinkGetNominalOutputVideoRefreshPeriod( CVDisplayLinkRef CV_NONNULL displayLink );
>          |                  ^
>    ui/cocoa.m:664:13: error: 'CVDisplayLinkRelease' is deprecated: first deprecated in macOS 15.0 - use NSView.displayLink(target:selector:), NSWindow.displayLink(target:selector:), or NSScreen.displayLink(target:selector:)  [-Werror,-Wdeprecated-declarations]
>      664 |             CVDisplayLinkRelease(displayLink);
>          |             ^
>    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreVideo.framework/Headers/CVDisplayLink.h:249:16: note: 'CVDisplayLinkRelease' has been explicitly marked deprecated here
>      249 | CV_EXPORT void CVDisplayLinkRelease( CV_RELEASES_ARGUMENT CVDisplayLinkRef CV_NULLABLE displayLink );
>          |                ^
>    3 errors generated.
> 
> For the next release, ignore the warnings using #pragma directives.
> At least until we figure the correct new API usage.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   ui/cocoa.m | 5 +++++
>   1 file changed, 5 insertions(+)

Patch queued.
diff mbox series

Patch

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 4c2dd33532..0422dafde4 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -639,6 +639,9 @@  - (void) updateBounds
     [self setBoundsSize:NSMakeSize(screen.width, screen.height)];
 }
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+
 - (void) updateUIInfoLocked
 {
     /* Must be called with the BQL, i.e. via updateUIInfo */
@@ -685,6 +688,8 @@  - (void) updateUIInfoLocked
     dpy_set_ui_info(dcl.con, &info, TRUE);
 }
 
+#pragma GCC diagnostic pop
+
 - (void) updateUIInfo
 {
     if (!allow_events) {