Skip to content

Truly independent web browser

LibWebView: Remove support for legacy crash reports

Timothy Flynn9df0ba4f1126
diff --git a/Libraries/LibWebView/CrashReportStore.cpp b/Libraries/LibWebView/CrashReportStore.cpp
index ae77b924f5e..99c06bbb3cd 100644
--- a/Libraries/LibWebView/CrashReportStore.cpp
+++ b/Libraries/LibWebView/CrashReportStore.cpp
@@ -51,20 +51,13 @@ CrashReportStore& CrashReportStore::the()
bool CrashReportStore::is_saved_report_name(StringView name)
{
constexpr auto timestamp_pattern = "####-##-##T##-##-##Z-"sv;
- if (!name.ends_with(".txt"sv))
+ if (!name.ends_with(".txt"sv) || name.length() <= timestamp_pattern.length())
return false;
- auto suffix = name;
- if (name.length() > timestamp_pattern.length()) {
- bool has_timestamp = true;
- for (size_t i = 0; i < timestamp_pattern.length(); ++i) {
- if (timestamp_pattern[i] == '#' ? !is_ascii_digit(name[i]) : name[i] != timestamp_pattern[i]) {
- has_timestamp = false;
- break;
- }
- }
- if (has_timestamp)
- suffix = name.substring_view(timestamp_pattern.length());
+ for (size_t i = 0; i < timestamp_pattern.length(); ++i) {
+ if (timestamp_pattern[i] == '#' ? !is_ascii_digit(name[i]) : name[i] != timestamp_pattern[i])
+ return false;
}
+ auto suffix = name.substring_view(timestamp_pattern.length());
for (auto type : { ProcessType::Browser, ProcessType::WebContent,
ProcessType::RequestServer, ProcessType::ImageDecoder, ProcessType::MediaServer, ProcessType::AudioServer, ProcessType::VideoDecoderServer, ProcessType::Compositor }) {
auto prefix = ByteString::formatted("{}-", process_name_from_type(type));
@@ -84,7 +77,6 @@ static constexpr auto pending_suffix = ".pending"sv;
static constexpr off_t maximum_report_size = 1048576;
static constexpr size_t retained_report_count = 20;
static constexpr size_t maximum_waiting_report_count = 100;
-static constexpr auto hard_cutoff_date = UnixDateTime::from_unix_time_parts(2026, 10, 2, 20, 0, 0, 0);
static constexpr auto maximum_unsent_report_age = AK::Duration::from_seconds(30ll * 24 * 60 * 60);
static NeverDestroyed<ByteString> s_browser_pending_path;
@@ -259,7 +251,7 @@ ErrorOr<Vector<ByteString>> CrashReportStore::pending_report_names(UnixDateTime
{
// Runs on every launch, so this only lists names instead of reading every report.
auto directory = TRY(open_report_directory(m_directory));
- auto earliest_time = max(hard_cutoff_date, now - maximum_unsent_report_age);
+ auto earliest_time = now - maximum_unsent_report_age;
Vector<ByteString> names;
Core::DirIterator iterator(directory.path().string(), Core::DirIterator::SkipDots);
diff --git a/Libraries/LibWebView/CrashReportStore.h b/Libraries/LibWebView/CrashReportStore.h
index ed5c4cafd47..df2fc651967 100644
--- a/Libraries/LibWebView/CrashReportStore.h
+++ b/Libraries/LibWebView/CrashReportStore.h
@@ -43,8 +43,7 @@ public:
Optional<String> website(ByteString const& name) const;
ErrorOr<void> remove_websites_saved_since(UnixDateTime) const;
- // The reports waiting to be reviewed, newest first. A report of a crash from before the hard cutoff date
- // (October 2, 2026 20:00 UTC) or more than 30 days before `now` is never pending.
+ // The reports waiting to be reviewed, newest first. A report of a crash more than 30 days before `now` is never pending.
ErrorOr<Vector<ByteString>> pending_report_names(UnixDateTime now = UnixDateTime::now()) const;
// Seen reports move into a subdirectory, where the newest of them are kept for reference and never offered again.
diff --git a/Tests/LibWebView/TestCrashReportReview.cpp b/Tests/LibWebView/TestCrashReportReview.cpp
index 27d7d920268..12dc3e8d521 100644
--- a/Tests/LibWebView/TestCrashReportReview.cpp
+++ b/Tests/LibWebView/TestCrashReportReview.cpp
@@ -124,11 +124,10 @@ TEST_CASE(the_crash_date_is_read_from_the_report_and_not_from_its_name)
VERIFY(setenv("TZ", "XYZ-2", 1) == 0);
tzset();
- // Reports saved before names carried the time of the crash have no time to take from their names.
- write_named_report("WebContent-legacy.txt"sv, report_text);
+ auto name = write_report("2026-10-02T00-00-00Z"sv);
WebView::CrashReportStore store { test_directory() };
CrashReportReview review { store };
- auto report = MUST(review.open(ByteString { "WebContent-legacy.txt"sv }));
+ auto report = MUST(review.open(name));
EXPECT_EQ(report.fields[0].label, "Crash date"sv);
EXPECT_EQ(report.fields[0].value, "2026-10-01 14:34:56"sv);
@@ -139,10 +138,10 @@ TEST_CASE(a_report_that_does_not_say_when_it_crashed_has_no_crash_date)
cleanup();
ScopeGuard guard = cleanup;
- write_named_report("WebContent-legacy.txt"sv, "Ladybird crash report, format 1\nProcess: WebContent\nCrashed at: yesterday\n"sv);
+ auto name = write_report("2026-10-02T00-00-00Z"sv, "Ladybird crash report, format 1\nProcess: WebContent\nCrashed at: yesterday\n"sv);
WebView::CrashReportStore store { test_directory() };
CrashReportReview review { store };
- auto report = MUST(review.open(ByteString { "WebContent-legacy.txt"sv }));
+ auto report = MUST(review.open(name));
for (auto const& field : report.fields)
EXPECT(field.label != "Crash date"sv);
diff --git a/Tests/LibWebView/TestCrashReportStore.cpp b/Tests/LibWebView/TestCrashReportStore.cpp
index 8a44a8f9634..80e5dd9bea6 100644
--- a/Tests/LibWebView/TestCrashReportStore.cpp
+++ b/Tests/LibWebView/TestCrashReportStore.cpp
@@ -90,6 +90,8 @@ TEST_CASE(a_stored_report_is_named_after_the_time_of_the_crash)
TEST_CASE(unrelated_files_are_not_reports)
{
EXPECT(!WebView::CrashReportStore::is_saved_report_name("notes.txt"sv));
+ EXPECT(!WebView::CrashReportStore::is_saved_report_name("WebContent-abc123.txt"sv));
+ EXPECT(!WebView::CrashReportStore::is_saved_report_name("2026-03-04X05-06-07Z-WebContent-abc123.txt"sv));
EXPECT(!WebView::CrashReportStore::is_saved_report_name("2026-03-04T05-06-07Z-Firefox-abc123.txt"sv));
EXPECT(!WebView::CrashReportStore::is_saved_report_name("2026-03-04T05-06-07Z-WebContent-abc123.log"sv));
EXPECT(WebView::CrashReportStore::is_saved_report_name("2026-03-04T05-06-07Z-WebContent-abc123.txt"sv));
@@ -170,25 +172,6 @@ TEST_CASE(a_seen_report_is_no_longer_pending)
EXPECT(!MUST(store.pending_report_names(now)).is_empty());
}
-TEST_CASE(a_report_from_before_the_hard_cutoff_date_is_not_pending)
-{
- cleanup();
- ScopeGuard guard = cleanup;
-
- auto before = report_name("2026-10-02T19-59-59Z"sv);
- auto at = report_name("2026-10-02T20-00-00Z"sv, "Browser"sv);
- write_file(before, "Too old\n"sv, UnixDateTime::from_unix_time_parts(2026, 10, 2, 19, 59, 59, 0));
- write_file(at, "Recent enough\n"sv, UnixDateTime::from_unix_time_parts(2026, 10, 2, 20, 0, 0, 0));
- auto store = test_store();
-
- auto soon_after = UnixDateTime::from_unix_time_parts(2026, 10, 3, 0, 0, 0, 0);
- EXPECT_EQ(MUST(store.pending_report_names(soon_after)), Vector<ByteString> { at });
-
- // The report is only ignored, so it can still be read.
- EXPECT_EQ(MUST(store.saved_report(before)).text, "Too old\n"sv);
- EXPECT_EQ(directory_entries().size(), 2u);
-}
-
TEST_CASE(a_report_older_than_30_days_is_not_pending)
{
cleanup();
@@ -238,7 +221,7 @@ TEST_CASE(a_stored_report_is_as_old_as_its_crash)
// A crash recovered at a later launch is still as old as when it happened.
auto store = test_store();
- auto crashed_at = UnixDateTime::from_unix_time_parts(2026, 10, 3, 0, 0, 0, 0);
+ auto crashed_at = UnixDateTime::from_unix_time_parts(2026, 2, 25, 0, 0, 0, 0);
auto name = MUST(store.store_report(WebView::ProcessType::Browser, "A report\n"sv, crashed_at));
EXPECT_EQ(MUST(store.pending_report_names(crashed_at + AK::Duration::from_seconds(30 * 24 * 60 * 60))), Vector<ByteString> { name });
@@ -295,16 +278,6 @@ TEST_CASE(retention_only_drops_the_oldest_seen_reports)
for (u32 i = 0; i < 3; ++i)
awaiting_review.append(store_report_modified_at(i, 500 + i));
- // Reports saved before names began with the crash time are seen reports like any other.
- auto legacy_name = "WebContent-legacy.txt"sv;
- write_file(legacy_name, "A legacy report\n"sv);
- {
- timespec times[2] { { 1, 0 }, { 1, 0 } };
- auto file = MUST(directory.open(legacy_name, Core::File::OpenMode::Read));
- VERIFY(futimens(file->fd(), times) == 0);
- }
- MUST(store.mark_seen(legacy_name));
-
Vector<ByteString> seen;
for (u32 i = 0; i < 21; ++i) {
seen.append(store_report_modified_at(100 + i, 1000 + i));
@@ -318,7 +291,6 @@ TEST_CASE(retention_only_drops_the_oldest_seen_reports)
auto seen_entries = directory_entries("Seen"sv);
EXPECT_EQ(seen_entries.size(), 20u);
- EXPECT(!seen_entries.contains_slow(legacy_name));
EXPECT(!seen_entries.contains_slow(seen[0]));
for (auto const& name : seen.span().slice(1))
EXPECT(seen_entries.contains_slow(name));