Skip to content

Commit

Permalink
qt6.qtwebengine: add aarch64-darwin support
Browse files Browse the repository at this point in the history
  • Loading branch information
wegank committed Jan 26, 2023
1 parent 6ace112 commit 7849094
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 6 deletions.
10 changes: 9 additions & 1 deletion pkgs/development/libraries/qt-6/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,15 @@ let
qtvirtualkeyboard = callPackage ./modules/qtvirtualkeyboard.nix { };
qtwayland = callPackage ./modules/qtwayland.nix { };
qtwebchannel = callPackage ./modules/qtwebchannel.nix { };
qtwebengine = callPackage ./modules/qtwebengine.nix { };
qtwebengine = callPackage ./modules/qtwebengine.nix {
inherit (darwin) bootstrap_cmds cctools xnu;
inherit (darwin.apple_sdk_11_0) libpm libunwind;
inherit (darwin.apple_sdk_11_0.libs) sandbox;
inherit (darwin.apple_sdk_11_0.frameworks) AGL AVFoundation Cocoa
CoreLocation CoreML ForceFeedback GameController ImageCaptureCore
LocalAuthentication MediaAccessibility MediaPlayer MetalKit Network
Quartz ReplayKit SecurityInterface Vision;
};
qtwebsockets = callPackage ./modules/qtwebsockets.nix { };
qtwebview = callPackage ./modules/qtwebview.nix {
inherit (darwin.apple_sdk_11_0.frameworks) WebKit;
Expand Down
85 changes: 80 additions & 5 deletions pkgs/development/libraries/qt-6/modules/qtwebengine.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
, qtpositioning
, qtwebsockets
, buildPackages
, clang_14
, bison
, coreutils
, flex
Expand Down Expand Up @@ -67,6 +68,31 @@
, mesa
, xkeyboard_config
, enableProprietaryCodecs ? true
# darwin
, bootstrap_cmds
, cctools
, libpm
, libunwind
, sandbox
, xcbuild
, xnu
, AGL
, AVFoundation
, Cocoa
, CoreLocation
, CoreML
, ForceFeedback
, GameController
, ImageCaptureCore
, LocalAuthentication
, MediaAccessibility
, MediaPlayer
, MetalKit
, Network
, Quartz
, ReplayKit
, SecurityInterface
, Vision
}:

qtModule {
Expand All @@ -84,6 +110,8 @@ qtModule {
which
gn
nodejs
] ++ lib.optionals stdenv.isDarwin [
clang_14
];
doCheck = true;
outputs = [ "out" "dev" ];
Expand All @@ -94,6 +122,12 @@ qtModule {
# which cannot be set at the same time as -Wformat-security
hardeningDisable = [ "format" ];

patches = [
../patches/qtwebengine-darwin-no-extensions.patch
# requires macOS 12.0+
../patches/qtwebengine-darwin-no-low-latency.patch
];

postPatch = ''
# Patch Chromium build tools
(
Expand All @@ -109,7 +143,7 @@ qtModule {
substituteInPlace cmake/Functions.cmake \
--replace "/bin/bash" "${buildPackages.bash}/bin/bash"
'' + lib.optionalString (!stdenv.isDarwin) ''
sed -i -e '/lib_loader.*Load/s!"\(libudev\.so\)!"${lib.getLib systemd}/lib/\1!' \
src/3rdparty/chromium/device/udev_linux/udev?_loader.cc
Expand All @@ -124,6 +158,17 @@ qtModule {
--replace "QLibraryInfo::path(QLibraryInfo::DataPath)" "\"$out\"" \
--replace "QLibraryInfo::path(QLibraryInfo::TranslationsPath)" "\"$out/translations\"" \
--replace "QLibraryInfo::path(QLibraryInfo::LibraryExecutablesPath)" "\"$out/libexec\""
'' + lib.optionalString stdenv.isDarwin ''
substituteInPlace configure.cmake \
--replace "AppleClang" "Clang"
substituteInPlace cmake/Functions.cmake \
--replace "/usr/bin/xcrun" "${xcbuild}/bin/xcrun"
substituteInPlace src/3rdparty/chromium/build/config/mac/BUILD.gn \
--replace "\$mac_deployment_target" "${stdenv.targetPlatform.darwinSdkVersion}"
substituteInPlace src/gn/CMakeLists.txt \
--replace "REALPATH" "ABSOLUTE"
substituteInPlace src/3rdparty/chromium/third_party/crashpad/crashpad/util/BUILD.gn \
--replace "\$sysroot/usr" "${xnu}"
'';

cmakeFlags = [
Expand All @@ -143,9 +188,12 @@ qtModule {
# android only. https://bugreports.qt.io/browse/QTBUG-100293
# "-DQT_FEATURE_webengine_native_spellchecker=ON"
"-DQT_FEATURE_webengine_sanitizer=ON"
"-DQT_FEATURE_webengine_webrtc_pipewire=ON"
"-DQT_FEATURE_webengine_kerberos=ON"
] ++ lib.optional enableProprietaryCodecs "-DQT_FEATURE_webengine_proprietary_codecs=ON";
] ++ lib.optionals stdenv.isLinux [
"-DQT_FEATURE_webengine_webrtc_pipewire=ON"
] ++ lib.optionals enableProprietaryCodecs [
"-DQT_FEATURE_webengine_proprietary_codecs=ON"
];

propagatedBuildInputs = [
# Image formats
Expand Down Expand Up @@ -174,7 +222,7 @@ qtModule {

libevent
ffmpeg

] ++ lib.optionals (!stdenv.isDarwin) [
dbus
zlib
minizip
Expand Down Expand Up @@ -214,10 +262,36 @@ qtModule {

libkrb5
mesa
] ++ lib.optionals stdenv.isDarwin [
AGL
AVFoundation
Cocoa
CoreLocation
CoreML
ForceFeedback
GameController
ImageCaptureCore
LocalAuthentication
MediaAccessibility
MediaPlayer
MetalKit
Network
Quartz
ReplayKit
SecurityInterface
Vision
];

buildInputs = [
cups
] ++ lib.optionals stdenv.isDarwin [
bootstrap_cmds
cctools
libpm
libunwind
openbsm
sandbox
xcbuild
];

requiredSystemFeatures = [ "big-parallel" ];
Expand All @@ -234,7 +308,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;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
diff --git a/src/core/common/extensions/extensions_api_provider_qt.cpp b/src/core/common/extensions/extensions_api_provider_qt.cpp
index 1c8e897..5c4f20b 100644
--- a/src/core/common/extensions/extensions_api_provider_qt.cpp
+++ b/src/core/common/extensions/extensions_api_provider_qt.cpp
@@ -19,9 +19,9 @@
#include "extensions/grit/extensions_resources.h"
#include "qtwebengine/common/extensions/api/generated_schemas.h"

-#include "qt_api_features.h"
+//#include "qt_api_features.h"
//#include "qt_behavior_features.h"
-#include "qt_permission_features.h"
+//#include "qt_permission_features.h"
//#include "qt_manifest_features.h"


@@ -37,7 +37,7 @@ void ExtensionsAPIProviderQt::RegisterManifestHandlers()

void ExtensionsAPIProviderQt::AddAPIFeatures(FeatureProvider *provider)
{
- AddQtAPIFeatures(provider);
+ //AddQtAPIFeatures(provider);
}

void ExtensionsAPIProviderQt::AddAPIJSONSources(JSONFeatureProviderSource *json_source)
@@ -47,7 +47,7 @@ void ExtensionsAPIProviderQt::AddAPIJSONSources(JSONFeatureProviderSource *json_

void ExtensionsAPIProviderQt::AddPermissionFeatures(FeatureProvider *provider)
{
- AddQtPermissionFeatures(provider);
+ //AddQtPermissionFeatures(provider);
}

bool ExtensionsAPIProviderQt::IsAPISchemaGenerated(const std::string &name)
Original file line number Diff line number Diff line change
@@ -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<CFTypeRef> 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<CFDictionaryRef> 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;

0 comments on commit 7849094

Please sign in to comment.