[vlc-devel] [PATCH] macosx: add a nag screen when executing the Intel binary on ARM-64
David Fuhrmann
david.fuhrmann at gmail.com
Mon Dec 7 11:33:51 CET 2020
> Am 06.12.2020 um 16:23 schrieb Felix Paul Kühne <fkuehne at videolan.org>:
>
> From: Felix Paul Kühne <felix at feepk.net>
>
> ---
> modules/gui/macosx/VLCMain.m | 47 +++++++++++++++++++++++++++++++++++-
> 1 file changed, 46 insertions(+), 1 deletion(-)
>
> diff --git a/modules/gui/macosx/VLCMain.m b/modules/gui/macosx/VLCMain.m
> index 3e08c48da9..a2872c2dc8 100644
> --- a/modules/gui/macosx/VLCMain.m
> +++ b/modules/gui/macosx/VLCMain.m
> @@ -1,7 +1,7 @@
> /*****************************************************************************
> * VLCMain.m: MacOS X interface module
> *****************************************************************************
> - * Copyright (C) 2002-2016 VLC authors and VideoLAN
> + * Copyright (C) 2002-2020 VLC authors and VideoLAN
> * $Id$
> *
> * Authors: Derk-Jan Hartman <hartman at videolan.org>
> @@ -35,6 +35,7 @@
>
> #include <stdlib.h> /* malloc(), free() */
> #include <string.h>
> +#include <sys/sysctl.h>
> #include <vlc_common.h>
> #include <vlc_atomic.h>
> #include <vlc_actions.h>
> @@ -319,6 +320,50 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
> if (kidsAround && var_GetBool(p_playlist, "playlist-autostart"))
> playlist_Control(p_playlist, PLAYLIST_PLAY, true);
> PL_UNLOCK;
> +
> + /* on macOS 11 and later, check whether the user attempts to deploy
> + * the x86_64 binary on ARM-64 - if yes, run a nag screen */
> + if (OSX_BIGSUR_AND_HIGHER) {
> + if ([self processIsTranslated] > 0) {
> + msg_Warn(p_intf, "Process is translated!");
> + [self runNagScreen];
> + }
> + }
> +}
> +
> +- (int)processIsTranslated
> +{
> + int ret = 0;
> + size_t size = sizeof(ret);
> + if (sysctlbyname("sysctl.proc_translated", &ret, &size, NULL, 0) == -1) {
> + if (errno == ENOENT)
> + return 0;
> + return -1;
> + }
> + return ret;
> +}
> +
> +- (void)runNagScreen
> +{
> + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
> + if ([defaults boolForKey:@"NeverRunIntelNagScreenAgain"]) {
> + return;;
> + }
> +
> + NSAlert *alert = [NSAlert alertWithMessageText:_NS("VLC runs in translation mode")
> + defaultButton:_NS("Open Website")
> + alternateButton:_NS("Continue")
> + otherButton:_NS("Don't ask again")
> + informativeTextWithFormat:@"%@", _NS("This version of VLC is intended for Intel-based Macs only. For vastly improved performance, download VLC for Apple Silicon from our website.")];
> + [alert setAlertStyle:NSCriticalAlertStyle];
> +
> + NSInteger returnValue = [alert runModal];
> + if (returnValue == NSAlertDefaultReturn) {
> + NSURL *url = [NSURL URLWithString: @"https://www.videolan.org/vlc/download-macosx.html"];
> + [[NSWorkspace sharedWorkspace] openURL: url];
> + } else if (returnValue == NSAlertOtherReturn) {
> + [defaults setBool:YES forKey:@"NeverRunIntelNagScreenAgain"];
> + }
As discussed already over IRC, in my personal opinion this nag screen is rather user unfriendly and annoying, and the best way would be to utilise sparkle to ensure VLC users on ARM get the arm version automatically.
Making a universal build (maybe for 3.0.12 only) would be an easy way to solve this problem nicely. But considering we do not want to do universal builds:
What do you think about this way to achieve this: We could do a 3.0.12 release, and then directly afterwards a 3.0.12.1 for macOS arm only. Then ARM people could update to the correct version in 2 steps, using sparkle. This would work if we implement the runtime detection for the URL, as mentioned in my other mail.
Best regards,
David
More information about the vlc-devel
mailing list