summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2023-03-20 14:10:00 +0100
committerMichal Klocek <michal.klocek@qt.io>2023-05-03 12:35:32 +0200
commitbd1d854d03f169f005511b2204d124dc05213571 (patch)
tree4a3c5ddcf59ccb00e4388358c493f0c73d20dea7
parent8dfb4a3c514e2fcb6b65684c8e263ff180c6d06b (diff)
downloadqtwebengine-bd1d854d03f169f005511b2204d124dc05213571.tar.gz
Add v8 context snapshot support/feature
Change-Id: I93e615293160d80c8a65b0152d2f820cfadbdb9d Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--src/core/CMakeLists.txt6
-rw-r--r--src/core/api/CMakeLists.txt15
-rw-r--r--src/core/api/configure.cmake5
-rw-r--r--src/core/configure/BUILD.root.gn.in9
-rw-r--r--src/core/content_main_delegate_qt.cpp2
-rw-r--r--src/core/web_engine_library_info.cpp2
6 files changed, 34 insertions, 5 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 735088dd2..f3909eb16 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -335,13 +335,15 @@ foreach(arch ${archs})
toolkit_views=false
chrome_pgo_phase=0
optimize_webui=false
- v8_use_external_startup_data=false
strip_absolute_paths_from_debug_symbols=false
devtools_fast_bundle=false
devtools_skip_typecheck=false
enable_jxl_decoder=false # temporarily because libjxl causes internal compiler error on armv7
)
-
+ extend_gn_list(gnArgArg
+ ARGS use_v8_context_snapshot v8_use_external_startup_data
+ CONDITION QT_FEATURE_webengine_v8_context_snapshot
+ )
extend_gn_list(gnArgArg
ARGS enable_basic_printing enable_print_preview enable_pdf
CONDITION QT_FEATURE_webengine_printing_and_pdf
diff --git a/src/core/api/CMakeLists.txt b/src/core/api/CMakeLists.txt
index 32b3451bd..9954139e5 100644
--- a/src/core/api/CMakeLists.txt
+++ b/src/core/api/CMakeLists.txt
@@ -79,6 +79,7 @@ qt_internal_extend_target(WebEngineCore CONDITION QT_FEATURE_webengine_geolocati
get_install_config(config)
get_architectures(archs)
+get_configs(configs)
list(GET archs 0 arch)
##
@@ -114,7 +115,16 @@ set(resourceList qtwebengine_resources.pak
qtwebengine_resources_200p.pak
qtwebengine_devtools_resources.pak)
-
+if(QT_FEATURE_webengine_v8_context_snapshot AND NOT MACOS)
+ list(APPEND resourceList v8_context_snapshot.bin)
+elseif(QT_FEATURE_webengine_v8_context_snapshot)
+ foreach(arch ${archs})
+ foreach(config ${configs})
+ get_filename_component(resSourcePath ${buildDir}/${config}/${arch}/v8_context_snapshot.${arch}.bin REALPATH)
+ list(APPEND resourceFiles ${resSourcePath})
+ endforeach()
+ endforeach()
+endif()
foreach(loc ${localeList})
get_filename_component(locSourcePath ${buildDir}/${config}/${arch}/qtwebengine_locales/${loc}.pak REALPATH)
@@ -126,7 +136,8 @@ foreach(res ${resourceList})
list(APPEND resourceFiles ${resSourcePath})
endforeach()
-if (NOT QT_FEATURE_webengine_system_icu)
+
+if(NOT QT_FEATURE_webengine_system_icu)
get_filename_component(icuFile ${buildDir}/${config}/${arch}/icudtl.dat REALPATH)
list(APPEND resourceFiles ${icuFile})
set_target_properties(WebEngineCore PROPERTIES ICUDTL_FILE ${icuFile})
diff --git a/src/core/api/configure.cmake b/src/core/api/configure.cmake
index df7583e25..c19f18251 100644
--- a/src/core/api/configure.cmake
+++ b/src/core/api/configure.cmake
@@ -64,6 +64,10 @@ qt_feature("webengine-system-alsa" PRIVATE
LABEL "Use ALSA"
CONDITION UNIX AND TEST_alsa
)
+qt_feature("webengine-v8-context-snapshot" PRIVATE
+ LABEL "Use v8 context snapshot"
+ CONDITION NOT CMAKE_CROSSCOMPILING
+)
qt_feature("webengine-geolocation" PUBLIC
LABEL "Geolocation"
CONDITION TARGET Qt::Positioning
@@ -204,6 +208,7 @@ qt_configure_add_summary_entry(
ARGS "webengine-system-pulseaudio"
CONDITION LINUX
)
+qt_configure_add_summary_entry(ARGS "webengine-v8-context-snapshot")
qt_configure_end_summary_section() # end of "Qt WebEngineCore" section
if(CMAKE_CROSSCOMPILING)
check_thumb(armThumb)
diff --git a/src/core/configure/BUILD.root.gn.in b/src/core/configure/BUILD.root.gn.in
index 67b02701a..86369cbbb 100644
--- a/src/core/configure/BUILD.root.gn.in
+++ b/src/core/configure/BUILD.root.gn.in
@@ -11,6 +11,7 @@ import("//build/config/locales.gni")
import("//chrome/chrome_repack_locales.gni")
import("//extensions/buildflags/buildflags.gni")
import("//ui/ozone/ozone.gni")
+import("//tools/v8_context_snapshot/v8_context_snapshot.gni")
# Workaround for cmake configure_file command. Words wrapped with @ characters are
# handled as variables in this file.
@@ -109,6 +110,7 @@ shared_library("QtWebEngineCore") {
"//third_party/boringssl/src/include",
"//third_party/skia/include/core"
]
+ data_deps = []
defines = [ "CHROMIUM_VERSION=" + chromium_version[0] ]
deps = [
"//base",
@@ -165,7 +167,7 @@ shared_library("QtWebEngineCore") {
if (is_win) {
configs += [ "//build/config/compiler:rtti" ]
- data_deps = [ ":QtWebEngineCoreSandbox" ]
+ data_deps += [ ":QtWebEngineCoreSandbox" ]
}
if (use_embedded_config) {
configs += [ ":embedded_config" ]
@@ -186,6 +188,11 @@ shared_library("QtWebEngineCore") {
":generate_cpp_mocs",
]
}
+ if (use_v8_context_snapshot) {
+ data_deps += [
+ "//tools/v8_context_snapshot:v8_context_snapshot"
+ ]
+ }
}
source_set("qtwebengine_spellcheck_sources") {
diff --git a/src/core/content_main_delegate_qt.cpp b/src/core/content_main_delegate_qt.cpp
index 52e23399e..2033a296b 100644
--- a/src/core/content_main_delegate_qt.cpp
+++ b/src/core/content_main_delegate_qt.cpp
@@ -262,6 +262,8 @@ absl::optional<int> ContentMainDelegateQt::BasicStartupComplete()
{
SafeOverridePath(base::FILE_EXE, WebEngineLibraryInfo::getPath(base::FILE_EXE));
SafeOverridePath(base::DIR_QT_LIBRARY_DATA, WebEngineLibraryInfo::getPath(base::DIR_QT_LIBRARY_DATA));
+ SafeOverridePath(base::DIR_ASSETS, WebEngineLibraryInfo::getPath(base::DIR_ASSETS));
+ SafeOverridePath(base::DIR_EXE, WebEngineLibraryInfo::getPath(base::DIR_ASSETS));
SafeOverridePath(ui::DIR_LOCALES, WebEngineLibraryInfo::getPath(ui::DIR_LOCALES));
#if QT_CONFIG(webengine_spellchecker)
SafeOverridePath(base::DIR_APP_DICTIONARIES, WebEngineLibraryInfo::getPath(base::DIR_APP_DICTIONARIES));
diff --git a/src/core/web_engine_library_info.cpp b/src/core/web_engine_library_info.cpp
index 277317f6f..c03c9a3b2 100644
--- a/src/core/web_engine_library_info.cpp
+++ b/src/core/web_engine_library_info.cpp
@@ -378,6 +378,8 @@ base::FilePath WebEngineLibraryInfo::getPath(int key)
case base::DIR_APP_DICTIONARIES:
return toFilePath(dictionariesPath());
#endif
+ case base::DIR_ASSETS:
+ return toFilePath(resourcesPath());
default:
// Note: the path system expects this function to override the default
// behavior. So no need to log an error if we don't support a given