Skip to content

Truly independent web browser

Everywhere: Describe platform features in crash and web compat reports

Zaggy10244f02ba81efa7
diff --git a/Libraries/LibWebView/Application.cpp b/Libraries/LibWebView/Application.cpp
index 284176d4ee2..ac7ffb97c19 100644
--- a/Libraries/LibWebView/Application.cpp
+++ b/Libraries/LibWebView/Application.cpp
@@ -2043,10 +2043,12 @@ void Application::reevaluate_platform_features()
SupportUI::platform_features_changed();
}
-JsonObject Application::platform_features_report() const
+JsonArray Application::platform_features_json(Optional<FeatureProcess> process) const
{
JsonArray features;
for (auto feature : PlatformFeatures::all_features) {
+ if (process.has_value() && PlatformFeatures::process_of(feature) != *process)
+ continue;
auto const& status = m_platform_feature_decisions->status_of(feature);
if (status.state == FeatureStatus::State::NotBuilt)
continue;
@@ -2064,9 +2066,13 @@ JsonObject Application::platform_features_report() const
object.set("blocked_by"sv, PlatformFeatures::feature_id(*status.blocking_feature));
features.must_append(move(object));
}
+ return features;
+}
+JsonObject Application::platform_features_report() const
+{
JsonObject report;
- report.set("features"sv, move(features));
+ report.set("features"sv, platform_features_json({}));
report.set("describes_gpu"sv, PlatformFeatures::this_build.paints_through_vulkan);
report.set("describes_ffmpeg"sv, PlatformFeatures::this_build.decodes_video_through_vulkan());
report.set("facts"sv, m_system_facts.to_json());
@@ -2075,6 +2081,31 @@ JsonObject Application::platform_features_report() const
return report;
}
+ByteString Application::describe_platform_features_for_report(Optional<FeatureProcess> process) const
+{
+ StringBuilder builder;
+ builder.appendff("Platform features: {}\n", platform_features_json(process).serialized());
+
+ if (auto const& gpu = m_system_facts.gpu; gpu.has_value()) {
+ builder.appendff("GPU device: {} ({:04x}:{:04x})\n", gpu->device_name, gpu->vendor_id, gpu->device_id);
+ builder.appendff("GPU driver: {} {}\n", gpu->driver_name, gpu->driver_info);
+ }
+
+ // The identity is unique to the machine, and no rule reads it.
+ auto facts = m_system_facts.to_json();
+ if (auto gpu = facts.get_object("gpu"sv); gpu.has_value())
+ gpu->remove("device_identity"sv);
+ builder.appendff("Platform facts: {}\n", facts.serialized());
+ if (m_system_facts.probe_failure.has_value())
+ builder.appendff("Platform probe failure: {}\n", *m_system_facts.probe_failure);
+
+ // Reports carry plain text, and drivers name themselves however they like.
+ StringBuilder sanitized;
+ for (auto character : builder.string_view())
+ sanitized.append(character == '\n' || is_ascii_printable(character) ? character : '?');
+ return sanitized.to_byte_string();
+}
+
void Application::when_platform_features_are_current(Function<void()> callback)
{
if (m_system_probe && !m_system_probe->has_finished()) {
diff --git a/Libraries/LibWebView/Application.h b/Libraries/LibWebView/Application.h
index 42077631818..5e50d143565 100644
--- a/Libraries/LibWebView/Application.h
+++ b/Libraries/LibWebView/Application.h
@@ -400,6 +400,9 @@ public:
PlatformFeatures::ProcessFeatures platform_features_for(FeatureProcess) const;
// Every feature's decision and the facts they were made from, for people to read.
JsonObject platform_features_report() const;
+ // The same as header lines of a report that leaves the machine: the features of one process or of all of them, the
+ // GPU, and every fact but the device's identity.
+ ByteString describe_platform_features_for_report(Optional<FeatureProcess>) const;
protected:
explicit Application(Optional<ByteString> ladybird_binary_path = {});
@@ -449,6 +452,7 @@ private:
WhenPlatformFeaturesAreCurrent,
};
CompositorLaunch prepare_platform_features();
+ JsonArray platform_features_json(Optional<FeatureProcess>) const;
void system_facts_arrived(SystemFacts const&);
void reevaluate_platform_features();
ErrorOr<void> launch_compositor_process();
diff --git a/Libraries/LibWebView/CrashReport.cpp b/Libraries/LibWebView/CrashReport.cpp
index af589712bf1..b929d284f84 100644
--- a/Libraries/LibWebView/CrashReport.cpp
+++ b/Libraries/LibWebView/CrashReport.cpp
@@ -177,6 +177,11 @@ ErrorOr<void> CrashReport::save(int wait_status, ByteString const& path, Optiona
builder.appendff("Process uptime (seconds): {}\n", (MonotonicTime::now() - m_started_at).to_seconds());
append_system_description(builder);
}
+ // A process without features says so, which tells it apart from a report written before there were any.
+ if (m_platform_features_description.is_empty())
+ builder.append("Platform features: []\n"sv);
+ else
+ builder.append(m_platform_features_description);
if (WIFSIGNALED(wait_status))
builder.appendff("Termination signal: {}\nTermination signal number: {}\n", signal_name(WTERMSIG(wait_status)), WTERMSIG(wait_status));
else if (WIFEXITED(wait_status))
diff --git a/Libraries/LibWebView/CrashReport.h b/Libraries/LibWebView/CrashReport.h
index 2df7e5d577a..acdbab3dbea 100644
--- a/Libraries/LibWebView/CrashReport.h
+++ b/Libraries/LibWebView/CrashReport.h
@@ -46,6 +46,10 @@ public:
ErrorOr<void> save(int wait_status, ByteString const& directory = CrashReportStore::the().directory(),
Optional<UnixDateTime> crashed_at = {});
+ // The platform features a helper was launched with, which stay as they were for its lifetime. A report without them
+ // says that the process has none.
+ void set_platform_features_description(ByteString description) { m_platform_features_description = move(description); }
+
explicit CrashReport(NonnullOwnPtr<Core::File> file, ProcessType process_type)
: m_file(move(file))
, m_process_type(process_type)
@@ -59,6 +63,7 @@ private:
[[maybe_unused]] ProcessType m_process_type;
MonotonicTime m_started_at { MonotonicTime::now() };
ByteString m_saved_name;
+ ByteString m_platform_features_description;
};
}
diff --git a/Libraries/LibWebView/CrashReportSubmission.cpp b/Libraries/LibWebView/CrashReportSubmission.cpp
index b606cd65167..2d4c0b6b6cc 100644
--- a/Libraries/LibWebView/CrashReportSubmission.cpp
+++ b/Libraries/LibWebView/CrashReportSubmission.cpp
@@ -46,6 +46,7 @@ static ReportSubmission::Contents describe_report(CrashReportSubmission::Options
contents.add("signal_number"sv, "number"sv, *diagnostics.signal.number);
contents.add_text("description"sv, "multiline"sv, options.description);
contents.add_text("url"sv, "text"sv, options.url);
+ contents.add_platform_features(text);
auto version = diagnostics.header("Version"sv);
auto build = diagnostics.header("Build configuration"sv);
diff --git a/Libraries/LibWebView/HelperProcess.cpp b/Libraries/LibWebView/HelperProcess.cpp
index 96a5f0738af..656a125146c 100644
--- a/Libraries/LibWebView/HelperProcess.cpp
+++ b/Libraries/LibWebView/HelperProcess.cpp
@@ -169,6 +169,20 @@ static ErrorOr<CPUProfiler> launch_cpu_profiler(StringView server_name, pid_t pi
#endif
}
+#if defined(AK_OS_MACOS) || defined(AK_OS_LINUX)
+static Optional<PlatformFeatures::FeatureProcess> feature_process_for(ProcessType process_type)
+{
+ switch (process_type) {
+ case ProcessType::Compositor:
+ return PlatformFeatures::FeatureProcess::Compositor;
+ case ProcessType::VideoDecoderServer:
+ return PlatformFeatures::FeatureProcess::VideoDecoderServer;
+ default:
+ return {};
+ }
+}
+#endif
+
// Spawns the helper with the given function, which returns the Process to keep track of, and returns the helper's
// identity.
template<typename SpawnFunction>
@@ -211,6 +225,8 @@ static ErrorOr<ChildIdentity> launch_helper_process(StringView server_name, Vect
warnln("Could not prepare {} crash reporting: {}", server_name, report.error());
} else {
crash_report = report.release_value();
+ if (auto feature_process = feature_process_for(process_type); feature_process.has_value())
+ crash_report->set_platform_features_description(WebView::Application::the().describe_platform_features_for_report(*feature_process));
// Reserve a distinct destination so dup2 clears close-on-exec
// in the child, including on the Linux fork/exec path.
auto child_fd = TRY(Core::System::fcntl(crash_report->fd(), F_DUPFD_CLOEXEC, 0));
diff --git a/Libraries/LibWebView/ReportSubmission.cpp b/Libraries/LibWebView/ReportSubmission.cpp
index 7e7576c4b76..0b6e05c7ded 100644
--- a/Libraries/LibWebView/ReportSubmission.cpp
+++ b/Libraries/LibWebView/ReportSubmission.cpp
@@ -75,6 +75,21 @@ void ReportSubmission::Contents::add_build_information(StringView platform, Stri
add_text("build_configuration"sv, "text"sv, build_configuration);
}
+void ReportSubmission::Contents::add_platform_features(StringView report_text)
+{
+ auto header = [&](StringView name) -> StringView {
+ for (auto line : report_text.split_view('\n')) {
+ if (line.starts_with(name) && line.substring_view(name.length()).starts_with(": "sv))
+ return line.substring_view(name.length() + 2);
+ }
+ return {};
+ };
+ if (auto features = JsonValue::from_string(header("Platform features"sv)); !features.is_error() && features.value().is_array())
+ add("platform_features"sv, "platform_features"sv, features.release_value());
+ add_text("gpu_device"sv, "text"sv, header("GPU device"sv));
+ add_text("gpu_driver"sv, "text"sv, header("GPU driver"sv));
+}
+
ByteString ReportSubmission::build_manifest(Contents const& contents, ReadonlySpan<Attachment> attachments)
{
JsonArray fields;
diff --git a/Libraries/LibWebView/ReportSubmission.h b/Libraries/LibWebView/ReportSubmission.h
index b5290f1fc95..1a2c472b04c 100644
--- a/Libraries/LibWebView/ReportSubmission.h
+++ b/Libraries/LibWebView/ReportSubmission.h
@@ -65,6 +65,8 @@ public:
void add(StringView key, StringView type, JsonValue value);
void add_text(StringView key, StringView type, StringView value);
void add_build_information(StringView platform, StringView architecture, StringView git_commit, StringView build_configuration);
+ // From the lines that Application::describe_platform_features_for_report() wrote into a report's text.
+ void add_platform_features(StringView report_text);
StringView kind;
ByteString client_version;
diff --git a/Libraries/LibWebView/WebCompatReport.cpp b/Libraries/LibWebView/WebCompatReport.cpp
index 8356fcfb237..4dac7d4ef71 100644
--- a/Libraries/LibWebView/WebCompatReport.cpp
+++ b/Libraries/LibWebView/WebCompatReport.cpp
@@ -119,7 +119,7 @@ void WebCompatReport::set_page_dumps(String dumps)
m_page_dumps = MUST(String::formatted("{}\n(Truncated)\n", StringView { bytes.slice(0, length) }));
}
-ByteString WebCompatReport::diagnostics(IncludePageDumps include_page_dumps) const
+ByteString WebCompatReport::diagnostics(IncludePageDumps include_page_dumps, IncludePlatformFeatures include_platform_features) const
{
StringBuilder builder;
builder.append("Ladybird web compatibility report, format 1\n"sv);
@@ -130,6 +130,9 @@ ByteString WebCompatReport::diagnostics(IncludePageDumps include_page_dumps) con
builder.appendff("Device pixel ratio: {}\n", m_page.device_pixel_ratio);
builder.appendff("Zoom level: {}\n", format_zoom_level(m_page.zoom_level));
+ if (include_platform_features == IncludePlatformFeatures::Yes && m_platform_features.has_value())
+ builder.append(*m_platform_features);
+
if (include_page_dumps == IncludePageDumps::Yes && m_page_dumps.has_value())
builder.appendff("\n{}", *m_page_dumps);
@@ -137,7 +140,7 @@ ByteString WebCompatReport::diagnostics(IncludePageDumps include_page_dumps) con
}
Optional<String> WebCompatReport::send(String const& description, Optional<ByteBuffer> screenshot_png,
- IncludePageDumps include_page_dumps)
+ IncludePageDumps include_page_dumps, IncludePlatformFeatures include_platform_features)
{
VERIFY(!m_submission);
@@ -146,7 +149,7 @@ Optional<String> WebCompatReport::send(String const& description, Optional<ByteB
if (screenshot_png.has_value() && screenshot_png->size() > maximum_screenshot_bytes)
return "This screenshot is too large to include in a report."_string;
- auto diagnostics_text = diagnostics(include_page_dumps);
+ auto diagnostics_text = diagnostics(include_page_dumps, include_platform_features);
Vector<ReportSubmission::Attachment> attachments;
attachments.append({
.id = diagnostics_reference,
@@ -177,6 +180,8 @@ Optional<String> WebCompatReport::send(String const& description, Optional<ByteB
contents.add("device_pixel_ratio"sv, "number"sv, m_page.device_pixel_ratio);
contents.add("zoom_level"sv, "number"sv, m_page.zoom_level);
contents.add_build_information(platform, architecture, LADYBIRD_COMMIT, build_configuration);
+ if (include_platform_features == IncludePlatformFeatures::Yes && m_platform_features.has_value())
+ contents.add_platform_features(*m_platform_features);
auto manifest = ReportSubmission::build_manifest(contents, attachments);
m_payload = ReportSubmission::Payload { move(manifest), move(attachments) };
diff --git a/Libraries/LibWebView/WebCompatReport.h b/Libraries/LibWebView/WebCompatReport.h
index c873614782e..cd6ab600382 100644
--- a/Libraries/LibWebView/WebCompatReport.h
+++ b/Libraries/LibWebView/WebCompatReport.h
@@ -47,6 +47,11 @@ public:
Yes,
};
+ enum class IncludePlatformFeatures : bool {
+ No,
+ Yes,
+ };
+
static Page describe_page(ViewImplementation const&);
static NonnullRefPtr<Core::Promise<String>> request_page_dumps(ViewImplementation&);
static Optional<String> validate(StringView description);
@@ -60,9 +65,12 @@ public:
void set_page_dumps(String);
bool has_page_dumps() const { return m_page_dumps.has_value(); }
- ByteString diagnostics(IncludePageDumps) const;
+ // Describes the GPU, its driver and the media libraries, and what the browser decided to use of them.
+ void set_platform_features(String description) { m_platform_features = move(description); }
+
+ ByteString diagnostics(IncludePageDumps, IncludePlatformFeatures = IncludePlatformFeatures::No) const;
- Optional<String> send(String const& description, Optional<ByteBuffer> screenshot_png, IncludePageDumps);
+ Optional<String> send(String const& description, Optional<ByteBuffer> screenshot_png, IncludePageDumps, IncludePlatformFeatures = IncludePlatformFeatures::No);
void retry();
bool is_sending() const { return m_submission; }
void cancel_sending();
@@ -77,6 +85,7 @@ private:
Page m_page;
Optional<String> m_page_dumps;
+ Optional<String> m_platform_features;
Optional<ReportSubmission::Payload> m_payload;
RefPtr<ReportSubmission> m_submission;
};
diff --git a/Services/Hub/ConnectionFromUI.cpp b/Services/Hub/ConnectionFromUI.cpp
index 50dd46b343b..bd24d6357bd 100644
--- a/Services/Hub/ConnectionFromUI.cpp
+++ b/Services/Hub/ConnectionFromUI.cpp
@@ -489,6 +489,11 @@ void ConnectionFromUI::view_request_page_dumps(u64 view_id, u64 request_id)
});
}
+void ConnectionFromUI::request_platform_features_description(u64 request_id)
+{
+ async_platform_features_description(request_id, Application::the().describe_platform_features_for_report({}));
+}
+
void ConnectionFromUI::view_prepare_for_immediate_close(u64 view_id)
{
auto* view = find_view(view_id);
diff --git a/Services/Hub/ConnectionFromUI.h b/Services/Hub/ConnectionFromUI.h
index 5051a180dac..04ea3e809d7 100644
--- a/Services/Hub/ConnectionFromUI.h
+++ b/Services/Hub/ConnectionFromUI.h
@@ -103,6 +103,7 @@ private:
virtual void view_request_selected_text(u64 view_id, u64 request_id) override;
virtual void view_request_close_preflight(u64 view_id, u64 request_id) override;
virtual void view_request_page_dumps(u64 view_id, u64 request_id) override;
+ virtual void request_platform_features_description(u64 request_id) override;
virtual void view_prepare_for_immediate_close(u64 view_id) override;
virtual void view_prepare_for_close_without_prompting(u64 view_id, u64 close_id) override;
virtual void finish_prepared_close(u64 close_id) override;
diff --git a/Services/Hub/HubClient.ipc b/Services/Hub/HubClient.ipc
index 65dc0660347..48ebfa6b5b4 100644
--- a/Services/Hub/HubClient.ipc
+++ b/Services/Hub/HubClient.ipc
@@ -242,6 +242,7 @@ endpoint HubClient
view_selected_text(u64 view_id, u64 request_id, Optional<ByteString> text) =|
view_close_preflight_finished(u64 view_id, u64 request_id, bool may_close) =|
view_page_dumps(u64 view_id, u64 request_id, Optional<String> dumps) =|
+ platform_features_description(u64 request_id, ByteString description) =|
pip_open(u64 view_id, u64 owner_view_id, Gfx::IntSize video_size) =|
pip_hide(u64 view_id) =|
pip_set_video_size(u64 view_id, Gfx::IntSize video_size) =|
diff --git a/Services/Hub/HubServer.ipc b/Services/Hub/HubServer.ipc
index 8e2d0fd8d51..444f8ae1c5e 100644
--- a/Services/Hub/HubServer.ipc
+++ b/Services/Hub/HubServer.ipc
@@ -181,6 +181,7 @@ endpoint HubServer
view_request_selected_text(u64 view_id, u64 request_id) =|
view_request_close_preflight(u64 view_id, u64 request_id) =|
view_request_page_dumps(u64 view_id, u64 request_id) =|
+ request_platform_features_description(u64 request_id) =|
view_prepare_for_immediate_close(u64 view_id) =|
view_prepare_for_close_without_prompting(u64 view_id, u64 close_id) =|
finish_prepared_close(u64 close_id) =|
diff --git a/Tests/LibWebView/TestCrashReport.cpp b/Tests/LibWebView/TestCrashReport.cpp
index 1588d27a6d8..483c47979a7 100644
--- a/Tests/LibWebView/TestCrashReport.cpp
+++ b/Tests/LibWebView/TestCrashReport.cpp
@@ -243,6 +243,34 @@ TEST_CASE(missing_or_malformed_capture_produces_a_minimal_report)
EXPECT(!text.contains(private_text));
}
+TEST_CASE(helper_reports_carry_the_platform_features_they_were_launched_with)
+{
+ cleanup();
+ ScopeGuard guard = cleanup;
+ auto report = MUST(WebView::CrashReport::create(WebView::ProcessType::Compositor));
+ constexpr auto description = "Platform features: [{\"id\":\"gpu_painting\",\"state\":\"Enabled\"}]\nGPU device: NVIDIA GeForce RTX 3090 (10de:2204)\nPlatform facts: {\"gpu\":{\"vendor_id\":4318}}\n"sv;
+ report->set_platform_features_description(description);
+ MUST(report->save(SIGSEGV, test_directory()));
+ auto paths = report_paths();
+ EXPECT_EQ(paths.size(), 1u);
+ auto file = MUST(Core::File::open(paths[0], Core::File::OpenMode::Read));
+ auto contents = MUST(file->read_until_eof());
+ EXPECT(StringView { contents }.contains(description));
+}
+
+TEST_CASE(reports_of_processes_without_platform_features_say_so)
+{
+ cleanup();
+ ScopeGuard guard = cleanup;
+ auto report = MUST(WebView::CrashReport::create(WebView::ProcessType::WebContent));
+ MUST(report->save(SIGSEGV, test_directory()));
+ auto paths = report_paths();
+ EXPECT_EQ(paths.size(), 1u);
+ auto file = MUST(Core::File::open(paths[0], Core::File::OpenMode::Read));
+ auto contents = MUST(file->read_until_eof());
+ EXPECT(StringView { contents }.contains("\nPlatform features: []\n"sv));
+}
+
TEST_CASE(invalid_frame_lengths_are_ignored)
{
cleanup();
diff --git a/Tests/LibWebView/TestCrashReportSubmission.cpp b/Tests/LibWebView/TestCrashReportSubmission.cpp
index a768be60605..0529a996de2 100644
--- a/Tests/LibWebView/TestCrashReportSubmission.cpp
+++ b/Tests/LibWebView/TestCrashReportSubmission.cpp
@@ -27,6 +27,10 @@ constexpr auto report_text = "Ladybird crash report, format 1\n"
"Process: WebContent\n"
"Version: 1.0\n"
"Build configuration: Release\n"
+ "Platform features: [{\"id\":\"gpu_painting\",\"state\":\"Enabled\"}]\n"
+ "GPU device: NVIDIA GeForce RTX 3090 (10de:2204)\n"
+ "GPU driver: NVIDIA 615.78.08\n"
+ "Platform facts: {}\n"
"Termination signal: SIGSEGV\n"
"Termination signal number: 11\n"
"\n"
@@ -132,6 +136,13 @@ TEST_CASE(crash_report_submission)
VERIFY(manifest_field(manifest, "url"sv)->as_string() == "https://example.com/"sv);
VERIFY(manifest_field(manifest, "signal"sv)->as_string() == "SIGSEGV"sv);
VERIFY(manifest_field(manifest, "process"sv)->as_string() == "WebContent"sv);
+ auto features = manifest_field(manifest, "platform_features"sv)->as_array();
+ VERIFY(features.size() == 1);
+ VERIFY(features.at(0).as_object().get_string("id"sv) == "gpu_painting"sv);
+ VERIFY(manifest_field(manifest, "gpu_device"sv)->as_string() == "NVIDIA GeForce RTX 3090 (10de:2204)"sv);
+ VERIFY(manifest_field(manifest, "gpu_driver"sv)->as_string() == "NVIDIA 615.78.08"sv);
+ // The full facts stay in the attached text.
+ VERIFY(!manifest_field(manifest, "platform_facts"sv).has_value());
auto attachments = manifest.get_array("attachments"sv).value();
VERIFY(attachments.size() == 1);
diff --git a/Tests/LibWebView/TestWebCompatReport.cpp b/Tests/LibWebView/TestWebCompatReport.cpp
index 1cd5522427c..d06050828f6 100644
--- a/Tests/LibWebView/TestWebCompatReport.cpp
+++ b/Tests/LibWebView/TestWebCompatReport.cpp
@@ -84,6 +84,12 @@ void verify_diagnostics()
VERIFY(diagnostics.contains("\nZoom level: 110%\n"sv));
VERIFY(diagnostics.contains("\nGit commit: "sv));
+ // The platform features are only in a report whose sender chose to include them.
+ constexpr auto platform_features = "Platform features: [{\"id\":\"gpu_painting\",\"state\":\"Enabled\"}]\nPlatform facts: {}\n"sv;
+ report.set_platform_features(String::from_utf8_without_validation(platform_features.bytes()));
+ VERIFY(report.diagnostics(WebCompatReport::IncludePageDumps::No) == diagnostics);
+ VERIFY(report.diagnostics(WebCompatReport::IncludePageDumps::No, WebCompatReport::IncludePlatformFeatures::Yes) == ByteString::formatted("{}{}", diagnostics, platform_features));
+
report.set_page_dumps(String::from_utf8_without_validation(page_dumps.bytes()));
VERIFY(report.has_page_dumps());
VERIFY(report.diagnostics(WebCompatReport::IncludePageDumps::Yes).ends_with(ByteString::formatted("\n\n{}", page_dumps)));
@@ -159,6 +165,8 @@ TEST_CASE(web_compat_report)
VERIFY(manifest_field(manifest, "zoom_level"sv)->get_double_with_precision_loss() == 1.1);
VERIFY(manifest_field(manifest, "platform"sv).has_value());
VERIFY(manifest_field(manifest, "git_commit"sv).has_value());
+ // The platform features are only sent when chosen.
+ VERIFY(!manifest_field(manifest, "platform_features"sv).has_value());
auto attachments = manifest.get_array("attachments"sv).value();
VERIFY(attachments.size() == 2);
diff --git a/UI/Qt/HubConnection.cpp b/UI/Qt/HubConnection.cpp
index 5c55785028b..b48bd8c20fa 100644
--- a/UI/Qt/HubConnection.cpp
+++ b/UI/Qt/HubConnection.cpp
@@ -711,6 +711,19 @@ void HubConnection::view_page_dumps(u64 view_id, u64 request_id, Optional<String
view->did_get_page_dumps(request_id, move(dumps));
}
+void HubConnection::fetch_platform_features_description(Function<void(ByteString)> callback)
+{
+ auto request_id = m_next_request_id++;
+ m_platform_features_description_requests.set(request_id, move(callback));
+ async_request_platform_features_description(request_id);
+}
+
+void HubConnection::platform_features_description(u64 request_id, ByteString description)
+{
+ if (auto callback = m_platform_features_description_requests.take(request_id); callback.has_value())
+ (*callback)(move(description));
+}
+
void HubConnection::app_open_new_tab(Vector<URL::URL> urls)
{
if (auto& application = Application::the(); application.on_new_tab)
diff --git a/UI/Qt/HubConnection.h b/UI/Qt/HubConnection.h
index 4f621e4e7e7..6e05a688df3 100644
--- a/UI/Qt/HubConnection.h
+++ b/UI/Qt/HubConnection.h
@@ -47,12 +47,16 @@ public:
void set_settings_from_hub(JsonValue const&);
void send_settings_changes(JsonValue const&);
+ // What the Hub decided about the GPU and media platform features, as a report describes it.
+ void fetch_platform_features_description(Function<void(ByteString)>);
+
private:
Core::GeolocationProvider* ensure_geolocation_provider();
bool m_did_initialize { false };
u64 m_next_request_id { 1 };
HashMap<u64, Function<void(RequestResponse)>> m_requests;
+ HashMap<u64, Function<void(ByteString)>> m_platform_features_description_requests;
OwnPtr<Core::GeolocationProvider> m_geolocation_provider;
HashMap<u64, Core::GeolocationProvider::RequestId> m_geolocation_requests;
HashMap<u64, Core::GeolocationProvider::WatchId> m_geolocation_watches;
@@ -82,6 +86,7 @@ private:
virtual void view_selected_text(u64 view_id, u64 request_id, Optional<ByteString> text) override;
virtual void view_close_preflight_finished(u64 view_id, u64 request_id, bool may_close) override;
virtual void view_page_dumps(u64 view_id, u64 request_id, Optional<String> dumps) override;
+ virtual void platform_features_description(u64 request_id, ByteString description) override;
virtual void pip_open(u64 view_id, u64 owner_view_id, Gfx::IntSize video_size) override;
virtual void pip_hide(u64 view_id) override;
virtual void pip_set_video_size(u64 view_id, Gfx::IntSize video_size) override;
diff --git a/UI/Qt/WebCompatReportReview.cpp b/UI/Qt/WebCompatReportReview.cpp
index a7a5ed616b2..f920315d42f 100644
--- a/UI/Qt/WebCompatReportReview.cpp
+++ b/UI/Qt/WebCompatReportReview.cpp
@@ -221,6 +221,17 @@ WebCompatReportReview::WebCompatReportReview(WebView::WebCompatReport::Page page
page_dumps_layout->addWidget(page_dumps_note);
review_layout->addWidget(page_dumps);
+ auto* platform_features = new QWidget(m_review_page);
+ auto* platform_features_layout = create_group_layout(platform_features);
+ m_include_platform_features = new QCheckBox(tr("Include graphics and video information"), platform_features);
+ m_include_platform_features->setObjectName("WebCompatReportIncludePlatformFeatures");
+ m_include_platform_features->setEnabled(false);
+ platform_features_layout->addWidget(m_include_platform_features);
+ auto* platform_features_note = create_label(tr("Helps us fix graphics and video bugs. It names your graphics card, its driver and your media libraries."), platform_features);
+ platform_features_note->setForegroundRole(QPalette::PlaceholderText);
+ platform_features_layout->addWidget(platform_features_note);
+ review_layout->addWidget(platform_features);
+
m_validation = create_label({}, m_review_page);
m_validation->setObjectName("WebCompatReportValidation");
m_validation->hide();
@@ -390,6 +401,19 @@ WebView::WebCompatReport::IncludePageDumps WebCompatReportReview::include_page_d
return m_include_page_dumps->isChecked() ? WebView::WebCompatReport::IncludePageDumps::Yes : WebView::WebCompatReport::IncludePageDumps::No;
}
+void WebCompatReportReview::set_platform_features(ByteString const& description)
+{
+ m_report.set_platform_features(String::from_utf8_with_replacement_character(description));
+ m_include_platform_features->setEnabled(true);
+}
+
+WebView::WebCompatReport::IncludePlatformFeatures WebCompatReportReview::include_platform_features() const
+{
+ if (!m_include_platform_features->isChecked())
+ return WebView::WebCompatReport::IncludePlatformFeatures::No;
+ return WebView::WebCompatReport::IncludePlatformFeatures::Yes;
+}
+
void WebCompatReportReview::send()
{
auto description = ak_string_from_qstring(m_description_edit->toPlainText());
@@ -412,7 +436,7 @@ void WebCompatReportReview::send()
m_validation->hide();
show_progress(WebView::ReportSubmission::Stage::Preparing);
- if (auto error = m_report.send(description, AK::move(screenshot), include_page_dumps()); error.has_value()) {
+ if (auto error = m_report.send(description, AK::move(screenshot), include_page_dumps(), include_platform_features()); error.has_value()) {
m_validation->setText(qstring_from_ak_string(*error));
m_validation->show();
show_page(*m_review_page);
@@ -428,7 +452,7 @@ void WebCompatReportReview::exit()
// The report is shown with the choices made so far, such as whether it includes layout and painting information.
void WebCompatReportReview::show_report_text()
{
- m_report_text->setPlainText(qstring_from_ak_string(String::from_utf8_with_replacement_character(m_report.diagnostics(include_page_dumps()))));
+ m_report_text->setPlainText(qstring_from_ak_string(String::from_utf8_with_replacement_character(m_report.diagnostics(include_page_dumps(), include_platform_features()))));
show_page(*m_report_text_page);
m_report_text->setFocus(Qt::OtherFocusReason);
}
diff --git a/UI/Qt/WebCompatReportReview.h b/UI/Qt/WebCompatReportReview.h
index 88756c32853..4a9a1e744c2 100644
--- a/UI/Qt/WebCompatReportReview.h
+++ b/UI/Qt/WebCompatReportReview.h
@@ -38,6 +38,7 @@ public:
void set_screenshot(QImage);
void set_page_dumps(String);
+ void set_platform_features(ByteString const&);
void show_progress(WebView::ReportSubmission::Stage);
void show_retry(String const& reason, u32 retry_number, u32 maximum_retries, u32 delay_seconds);
@@ -65,6 +66,7 @@ private:
void update_chrome_style();
WebView::WebCompatReport::IncludePageDumps include_page_dumps() const;
+ WebView::WebCompatReport::IncludePlatformFeatures include_platform_features() const;
WebView::WebCompatReport m_report;
QImage m_screenshot;
@@ -80,6 +82,7 @@ private:
QPushButton* m_select_screenshot_button { nullptr };
QPushButton* m_remove_screenshot_button { nullptr };
QCheckBox* m_include_page_dumps { nullptr };
+ QCheckBox* m_include_platform_features { nullptr };
QPushButton* m_show_report_button { nullptr };
QPlainTextEdit* m_report_text { nullptr };
QLabel* m_validation { nullptr };
diff --git a/UI/Qt/WebContentView.cpp b/UI/Qt/WebContentView.cpp
index e0c8dae0bfb..39baca7b371 100644
--- a/UI/Qt/WebContentView.cpp
+++ b/UI/Qt/WebContentView.cpp
@@ -1697,6 +1697,10 @@ void WebContentView::review_web_compat_report(WebCompatReportCapture capture)
.when_rejected([](Error const& error) {
warnln("Could not dump the page for a web compatibility report: {}", error);
});
+ HubConnection::the().fetch_platform_features_description([review = QPointer { review }](ByteString description) {
+ if (review)
+ review->set_platform_features(description);
+ });
m_web_compat_report_overlay->setGeometry(rect());
m_web_compat_report_overlay->show();