From 8c1e81959914e8e2e382687007c1f56e3a07ed5a Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Tue, 18 Apr 2023 18:48:33 +0300 Subject: [PATCH] qt6.qtwebengine: add aarch64-darwin support --- pkgs/development/libraries/qt-6/default.nix | 3 + .../libraries/qt-6/modules/qtwebengine.nix | 9 ++- ...ine-darwin-no-copy-certificate-chain.patch | 16 +++++ ...webengine-darwin-no-low-latency-flag.patch | 60 +++++++++++++++++++ 4 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 pkgs/development/libraries/qt-6/patches/qtwebengine-darwin-no-copy-certificate-chain.patch create mode 100644 pkgs/development/libraries/qt-6/patches/qtwebengine-darwin-no-low-latency-flag.patch diff --git a/pkgs/development/libraries/qt-6/default.nix b/pkgs/development/libraries/qt-6/default.nix index 45b1e536830e..931a9dc3fc7b 100644 --- a/pkgs/development/libraries/qt-6/default.nix +++ b/pkgs/development/libraries/qt-6/default.nix @@ -137,6 +137,9 @@ let GameController ImageCaptureCore LocalAuthentication MediaAccessibility MediaPlayer MetalKit Network OpenDirectory Quartz ReplayKit SecurityInterface Vision; + xcbuild = buildPackages.xcbuild.override { + productBuildVer = "20A2408"; + }; }; qtwebsockets = callPackage ./modules/qtwebsockets.nix { }; qtwebview = callPackage ./modules/qtwebview.nix { diff --git a/pkgs/development/libraries/qt-6/modules/qtwebengine.nix b/pkgs/development/libraries/qt-6/modules/qtwebengine.nix index 5b42d799accb..3741b7c6b6f0 100644 --- a/pkgs/development/libraries/qt-6/modules/qtwebengine.nix +++ b/pkgs/development/libraries/qt-6/modules/qtwebengine.nix @@ -127,6 +127,12 @@ qtModule { # which cannot be set at the same time as -Wformat-security hardeningDisable = [ "format" ]; + # removes macOS 12+ dependencies + patches = [ + ../patches/qtwebengine-darwin-no-low-latency-flag.patch + ../patches/qtwebengine-darwin-no-copy-certificate-chain.patch + ]; + postPatch = '' # Patch Chromium build tools ( @@ -301,7 +307,8 @@ qtModule { meta = with lib; { description = "A web engine based on the Chromium web browser"; - platforms = platforms.linux; + platforms = platforms.unix; + broken = stdenv.isDarwin && stdenv.isx86_64; # This build takes a long time; particularly on slow architectures # 1 hour on 32x3.6GHz -> maybe 12 hours on 4x2.4GHz timeout = 24 * 3600; diff --git a/pkgs/development/libraries/qt-6/patches/qtwebengine-darwin-no-copy-certificate-chain.patch b/pkgs/development/libraries/qt-6/patches/qtwebengine-darwin-no-copy-certificate-chain.patch new file mode 100644 index 000000000000..c7e461945c04 --- /dev/null +++ b/pkgs/development/libraries/qt-6/patches/qtwebengine-darwin-no-copy-certificate-chain.patch @@ -0,0 +1,16 @@ +diff --git a/src/3rdparty/chromium/net/cert/x509_util_apple.cc b/src/3rdparty/chromium/net/cert/x509_util_apple.cc +index ae69948dfca..7062a9a9b97 100644 +--- a/src/3rdparty/chromium/net/cert/x509_util_apple.cc ++++ b/src/3rdparty/chromium/net/cert/x509_util_apple.cc +@@ -139,11 +139,6 @@ SHA256HashValue CalculateFingerprint256(SecCertificateRef cert) { + + base::ScopedCFTypeRef CertificateChainFromSecTrust( + SecTrustRef trust) { +- if (__builtin_available(macOS 12.0, iOS 15.0, *)) { +- return base::ScopedCFTypeRef( +- SecTrustCopyCertificateChain(trust)); +- } +- + base::ScopedCFTypeRef chain( + CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks)); + const CFIndex chain_length = SecTrustGetCertificateCount(trust); diff --git a/pkgs/development/libraries/qt-6/patches/qtwebengine-darwin-no-low-latency-flag.patch b/pkgs/development/libraries/qt-6/patches/qtwebengine-darwin-no-low-latency-flag.patch new file mode 100644 index 000000000000..86507165bd9c --- /dev/null +++ b/pkgs/development/libraries/qt-6/patches/qtwebengine-darwin-no-low-latency-flag.patch @@ -0,0 +1,60 @@ +diff --git a/src/3rdparty/chromium/media/gpu/mac/vt_video_encode_accelerator_mac.cc b/src/3rdparty/chromium/media/gpu/mac/vt_video_encode_accelerator_mac.cc +index 6a3a777..249d4cc 100644 +--- a/src/3rdparty/chromium/media/gpu/mac/vt_video_encode_accelerator_mac.cc ++++ b/src/3rdparty/chromium/media/gpu/mac/vt_video_encode_accelerator_mac.cc +@@ -20,12 +20,6 @@ + #include "media/base/media_log.h" + #include "media/base/video_frame.h" + +-// This is a min version of macOS where we want to support SVC encoding via +-// EnableLowLatencyRateControl flag. The flag is actually supported since 11.3, +-// but there we see frame drops even with ample bitrate budget. Excessive frame +-// drops were fixed in 12.0.1. +-#define LOW_LATENCY_FLAG_AVAILABLE_VER 12.0.1 +- + namespace media { + + namespace { +@@ -150,8 +144,6 @@ VTVideoEncodeAccelerator::GetSupportedProfiles() { + profile.max_framerate_numerator = kMaxFrameRateNumerator; + profile.max_framerate_denominator = kMaxFrameRateDenominator; + profile.max_resolution = gfx::Size(kMaxResolutionWidth, kMaxResolutionHeight); +- if (__builtin_available(macOS LOW_LATENCY_FLAG_AVAILABLE_VER, *)) +- profile.scalability_modes.push_back(SVCScalabilityMode::kL1T2); + for (const auto& supported_profile : kSupportedProfiles) { + profile.profile = supported_profile; + profiles.push_back(profile); +@@ -595,13 +587,6 @@ bool VTVideoEncodeAccelerator::CreateCompressionSession( + kVTVideoEncoderSpecification_RequireHardwareAcceleratedVideoEncoder}; + std::vector encoder_values{kCFBooleanTrue}; + +- if (__builtin_available(macOS LOW_LATENCY_FLAG_AVAILABLE_VER, *)) { +- if (require_low_delay_) { +- encoder_keys.push_back( +- kVTVideoEncoderSpecification_EnableLowLatencyRateControl); +- encoder_values.push_back(kCFBooleanTrue); +- } +- } + base::ScopedCFTypeRef encoder_spec = + video_toolbox::DictionaryWithKeysAndValues( + encoder_keys.data(), encoder_values.data(), encoder_keys.size()); +@@ -669,19 +654,8 @@ bool VTVideoEncodeAccelerator::ConfigureCompressionSession() { + } + + if (num_temporal_layers_ == 2) { +- if (__builtin_available(macOS LOW_LATENCY_FLAG_AVAILABLE_VER, *)) { +- if (!session_property_setter.IsSupported( +- kVTCompressionPropertyKey_BaseLayerFrameRateFraction)) { +- DLOG(ERROR) << "BaseLayerFrameRateFraction is not supported"; +- return false; +- } +- rv &= session_property_setter.Set( +- kVTCompressionPropertyKey_BaseLayerFrameRateFraction, 0.5); +- DLOG_IF(ERROR, !rv) << " Setting BaseLayerFrameRate property failed."; +- } else { + DLOG(ERROR) << "SVC encoding is not supported on this OS version."; + rv = false; +- } + } + + return rv;