Skip to content

Support time zone change notifications on linux#64562

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
justinmichaud:eng/Support-time-zone-change-notifications-on-linux
May 22, 2026
Merged

Support time zone change notifications on linux#64562
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
justinmichaud:eng/Support-time-zone-change-notifications-on-linux

Conversation

@justinmichaud
Copy link
Copy Markdown
Contributor

@justinmichaud justinmichaud commented May 8, 2026

11993c8

Support time zone change notifications on linux
https://bugs.webkit.org/show_bug.cgi?id=314414

Reviewed by Yusuke Suzuki.

We add a timezone change observer for linux that watches both dbus
and /etc/localtime.

We add some testing helpers and some generated tests too. This uncovered
an existing bug with DST time changes.

* JSTests/stress/intl-datetimeformat-cache-dst-transition.js: Added.
(expect):
(setTimeout):
* JSTests/stress/intl-datetimeformat-cache-tz-hit.js: Added.
(expect):
(testTZ):
* JSTests/stress/intl-datetimeformat-cache-tz-watcher.js: Added.
(expect):
(slowTZ):
(setTimeout):
* JSTests/stress/intl-datetimeformat-stale-data-across-tz-change.js: Added.
(expect):
(setTimeout):
* JSTests/stress/temporal-cache-dst-transition.js: Added.
(expect):
(setTimeout):
* Source/JavaScriptCore/SaferCPPExpectations/UnretainedCallArgsCheckerExpectations:
* Source/JavaScriptCore/runtime/DateInstanceCache.h:
(JSC::DateInstanceCache::reset):
* Source/JavaScriptCore/runtime/JSDateMath.cpp:
(JSC::DateCache::DateCache):
(JSC::retrieveTimeZoneInformation):
(JSC::DateCache::clearForTimeZoneChange):
(JSC::timeZoneChangeNotification): Deleted.
(JSC::DateCache::resetIfNecessarySlow): Deleted.
* Source/JavaScriptCore/runtime/JSDateMath.h:
(JSC::DateCache::hasTimeZoneChange):
(JSC::DateCache::resetIfNecessary): Deleted.
* Source/JavaScriptCore/runtime/VM.cpp:
(JSC::VM::executeEntryScopeServicesOnEntry):
* Source/JavaScriptCore/tools/JSDollarVM.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
(JSC::JSDollarVM::finishCreation):
* Source/WTF/WTF.xcodeproj/project.pbxproj:
* Source/WTF/wtf/CMakeLists.txt:
* Source/WTF/wtf/PlatformCocoa.cmake:
* Source/WTF/wtf/PlatformGTK.cmake:
* Source/WTF/wtf/PlatformJSCOnly.cmake:
* Source/WTF/wtf/PlatformWPE.cmake:
* Source/WTF/wtf/TimeZone.cpp: Added.
(WTF::lastTimeZoneID):
(WTF::timeZoneDidChange):
(WTF::listenForTimeZoneChangeNotifications):
(WTF::setHostTimeZoneForTesting):
* Source/WTF/wtf/TimeZone.h: Added.
* Source/WTF/wtf/cocoa/TimeZoneCocoa.cpp: Added.
(WTF::timeZoneChangeNotification):
(WTF::listenForTimeZoneChangeNotifications):
* Source/WTF/wtf/glib/FilePathWatcher.cpp: Added.
(WTF::FilePathWatcher::FilePathWatcher):
(WTF::FilePathWatcher::~FilePathWatcher):
(WTF::FilePathWatcher::fileChangedCallback):
* Source/WTF/wtf/glib/FilePathWatcher.h: Added.
(WTF::FilePathWatcher::isActive const):
* Source/WTF/wtf/glib/TimeZoneGLib.cpp: Added.
(WTF::localtimeWatcher):
(WTF::timedate1Proxy):
(WTF::timedate1PropertiesChanged):
(WTF::onTimedate1ProxyReady):
(WTF::listenForTimeZoneChangeNotifications):
* Source/cmake/FindGLib.cmake:
* Tools/Scripts/run-gtk-tests:
* Tools/Scripts/run-timezone-glib-e2e-test: Added.
(find_testwtf):
(spawn_private_bus):
(own_timedate1):
(emit_timezone_changed):
(main):
* Tools/Scripts/run-wpe-tests:
* Tools/TestWebKitAPI/PlatformGTK.cmake:
* Tools/TestWebKitAPI/PlatformJSCOnly.cmake:
* Tools/TestWebKitAPI/PlatformWPE.cmake:
* Tools/TestWebKitAPI/Tests/WTF/glib/FilePathWatcher.cpp: Added.
(TestWebKitAPI::TEST(WTF_FilePathWatcher, FiresOnWrite)):
(TestWebKitAPI::TEST(WTF_FilePathWatcher, FiresOnSymlinkSwap)):
(TestWebKitAPI::TEST(WTF_FilePathWatcher, IgnoresUnrelatedSiblings)):
* Tools/TestWebKitAPI/Tests/WTF/glib/TimeZoneGLib.cpp: Added.
(TestWebKitAPI::WTF_TimeZoneGLib::SetUpTestSuite):
(TestWebKitAPI::WTF_TimeZoneGLib::TearDownTestSuite):
(TestWebKitAPI::TEST_F(WTF_TimeZoneGLib, FiresOnTimezonePropertyChange)):
(TestWebKitAPI::TEST_F(WTF_TimeZoneGLib, FiresOnInvalidatedTimezone)):
(TestWebKitAPI::TEST_F(WTF_TimeZoneGLib, IgnoresUnrelatedProperties)):
(TestWebKitAPI::TEST(WTF_TimeZoneGLib_External, ReceivesExternalSignal)):

Canonical link: https://commits.webkit.org/313750@main

b439d1e

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
❌ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ❌ 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 api-mac-debug ✅ 🛠 gtk3-libwebrtc
✅ 🛠 🧪 jsc-x86-64 ✅ 🧪 api-ios ✅ 🧪 mac-wk1 ✅ 🛠 gtk
✅ 🛠 🧪 jsc-debug-arm64 ✅ 🛠 ios-safer-cpp ✅ 🧪 mac-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🛠 playstation
✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2 ✅ 🛠 jsc-armv7
✅ 🛠 tv ✅ 🛠 mac-safer-cpp ✅ 🧪 jsc-armv7-tests
✅ 🛠 tv-sim ✅ 🧪 mac-site-isolation
✅ 🛠 watch
✅ 🛠 watch-sim

@justinmichaud justinmichaud requested review from a team as code owners May 8, 2026 18:12
@justinmichaud justinmichaud self-assigned this May 8, 2026
@justinmichaud justinmichaud added the JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues. label May 8, 2026
@justinmichaud justinmichaud force-pushed the eng/Support-time-zone-change-notifications-on-linux branch from cc3da80 to 246cf78 Compare May 8, 2026 18:13
Copy link
Copy Markdown
Member

@Constellation Constellation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can first try to use D-Bus, and then we can fallback to FilePathWatcher.

@justinmichaud justinmichaud marked this pull request as draft May 8, 2026 22:28
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 8, 2026
@webkit-ews-buildbot
Copy link
Copy Markdown
Collaborator

iOS Safer C++ Build #19907 (d875e19)

❌ Found 1 failing file with 1 issue. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming.
(cc @rniwa)

⚠️ Found 1 fixed file! Please update expectations in Source/[Project]/SaferCPPExpectations by running the following command and update your pull request:

  • Tools/Scripts/update-safer-cpp-expectations -p JavaScriptCore --UnretainedCallArgsChecker runtime/JSDateMath.cpp --platform iOS

@webkit-ews-buildbot
Copy link
Copy Markdown
Collaborator

macOS Safer C++ Build #101571 (d875e19)

❌ Found 1 failing file with 1 issue. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming.
(cc @rniwa)

⚠️ Found 1 fixed file! Please update expectations in Source/[Project]/SaferCPPExpectations by running the following command and update your pull request:

  • Tools/Scripts/update-safer-cpp-expectations -p JavaScriptCore --UnretainedCallArgsChecker runtime/JSDateMath.cpp --platform macOS

@justinmichaud justinmichaud force-pushed the eng/Support-time-zone-change-notifications-on-linux branch from d875e19 to c72caff Compare May 11, 2026 18:35
@webkit-ews-buildbot
Copy link
Copy Markdown
Collaborator

macOS Safer C++ Build #102002 (c72caff)

❌ Found 1 failing file with 1 issue. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming.
(cc @rniwa)

⚠️ Found 1 fixed file! Please update expectations in Source/[Project]/SaferCPPExpectations by running the following command and update your pull request:

  • Tools/Scripts/update-safer-cpp-expectations -p JavaScriptCore --UnretainedCallArgsChecker runtime/JSDateMath.cpp --platform macOS

@webkit-ews-buildbot
Copy link
Copy Markdown
Collaborator

iOS Safer C++ Build #20358 (c72caff)

❌ Found 1 failing file with 1 issue. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming.
(cc @rniwa)

⚠️ Found 1 fixed file! Please update expectations in Source/[Project]/SaferCPPExpectations by running the following command and update your pull request:

  • Tools/Scripts/update-safer-cpp-expectations -p JavaScriptCore --UnretainedCallArgsChecker runtime/JSDateMath.cpp --platform iOS

@justinmichaud justinmichaud force-pushed the eng/Support-time-zone-change-notifications-on-linux branch from c72caff to 85f8757 Compare May 12, 2026 13:33
@justinmichaud justinmichaud force-pushed the eng/Support-time-zone-change-notifications-on-linux branch from 85f8757 to 5be1bd5 Compare May 12, 2026 22:36
@justinmichaud justinmichaud removed the merging-blocked Applied to prevent a change from being merged label May 12, 2026
@justinmichaud justinmichaud marked this pull request as ready for review May 12, 2026 22:40
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 13, 2026
@justinmichaud justinmichaud force-pushed the eng/Support-time-zone-change-notifications-on-linux branch from 5be1bd5 to 5a95593 Compare May 14, 2026 00:47
@webkit-ews-buildbot
Copy link
Copy Markdown
Collaborator

macOS Safer C++ Build #102829 (5a95593)

❌ Found 1 failing file with 1 issue. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming.
(cc @rniwa)

Copy link
Copy Markdown
Member

@Constellation Constellation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, it is good to have some eyes from glib / GTK folks, but Cocoa side and JSC change looks fine to me.

Comment thread Source/JavaScriptCore/runtime/VM.cpp Outdated
// observe time zone changes.
dateCache.resetIfNecessary();
if (dateCache.hasTimeZoneChange()) [[unlikely]]
dateCache.clearForTimezoneChange();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Timezone => TimeZone?

auto scope = DECLARE_THROW_SCOPE(vm);

String tz = callFrame->argument(0).toWTFString(globalObject);
RETURN_IF_EXCEPTION(scope, encodedJSValue());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use { }

auto scope = DECLARE_THROW_SCOPE(vm);

String tz = callFrame->argument(0).toWTFString(globalObject);
RETURN_IF_EXCEPTION(scope, encodedJSValue());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use { }

@justinmichaud justinmichaud force-pushed the eng/Support-time-zone-change-notifications-on-linux branch from 5a95593 to 8c3cd87 Compare May 18, 2026 15:52
Comment on lines +164 to +167
if (name STREQUAL "GLib")
message(FATAL_ERROR "glib-2.0 is required")
endif ()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't have glib, then you get a recursion error instead of a proper error message. This mechanism requires the JSCOnly port to be built with glib now too (or rather, requires glib to run these tests), exposing this issue.

Comment thread Source/WTF/wtf/glib/TimeZoneGLib.cpp Outdated
{
static std::once_flag onceKey;
std::call_once(onceKey, [] {
localtimeWatcher() = makeUnique<FilePathWatcher>("/etc/localtime", [] {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably use an ASCIILiteral instead of a raw const char*.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. I opted for a string to allow dynamic paths to work too, WDYT?

Comment thread Source/WTF/wtf/glib/FilePathWatcher.cpp Outdated

WTF_MAKE_TZONE_ALLOCATED_IMPL(FilePathWatcher);

FilePathWatcher::FilePathWatcher(const char* path, Function<void()>&& handler)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ASCIILIteral instead of a raw const char*.

@justinmichaud justinmichaud force-pushed the eng/Support-time-zone-change-notifications-on-linux branch from 8c3cd87 to b439d1e Compare May 20, 2026 19:40
@justinmichaud justinmichaud added merge-queue Applied to send a pull request to merge-queue and removed merging-blocked Applied to prevent a change from being merged labels May 22, 2026
https://bugs.webkit.org/show_bug.cgi?id=314414

Reviewed by Yusuke Suzuki.

We add a timezone change observer for linux that watches both dbus
and /etc/localtime.

We add some testing helpers and some generated tests too. This uncovered
an existing bug with DST time changes.

* JSTests/stress/intl-datetimeformat-cache-dst-transition.js: Added.
(expect):
(setTimeout):
* JSTests/stress/intl-datetimeformat-cache-tz-hit.js: Added.
(expect):
(testTZ):
* JSTests/stress/intl-datetimeformat-cache-tz-watcher.js: Added.
(expect):
(slowTZ):
(setTimeout):
* JSTests/stress/intl-datetimeformat-stale-data-across-tz-change.js: Added.
(expect):
(setTimeout):
* JSTests/stress/temporal-cache-dst-transition.js: Added.
(expect):
(setTimeout):
* Source/JavaScriptCore/SaferCPPExpectations/UnretainedCallArgsCheckerExpectations:
* Source/JavaScriptCore/runtime/DateInstanceCache.h:
(JSC::DateInstanceCache::reset):
* Source/JavaScriptCore/runtime/JSDateMath.cpp:
(JSC::DateCache::DateCache):
(JSC::retrieveTimeZoneInformation):
(JSC::DateCache::clearForTimeZoneChange):
(JSC::timeZoneChangeNotification): Deleted.
(JSC::DateCache::resetIfNecessarySlow): Deleted.
* Source/JavaScriptCore/runtime/JSDateMath.h:
(JSC::DateCache::hasTimeZoneChange):
(JSC::DateCache::resetIfNecessary): Deleted.
* Source/JavaScriptCore/runtime/VM.cpp:
(JSC::VM::executeEntryScopeServicesOnEntry):
* Source/JavaScriptCore/tools/JSDollarVM.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
(JSC::JSDollarVM::finishCreation):
* Source/WTF/WTF.xcodeproj/project.pbxproj:
* Source/WTF/wtf/CMakeLists.txt:
* Source/WTF/wtf/PlatformCocoa.cmake:
* Source/WTF/wtf/PlatformGTK.cmake:
* Source/WTF/wtf/PlatformJSCOnly.cmake:
* Source/WTF/wtf/PlatformWPE.cmake:
* Source/WTF/wtf/TimeZone.cpp: Added.
(WTF::lastTimeZoneID):
(WTF::timeZoneDidChange):
(WTF::listenForTimeZoneChangeNotifications):
(WTF::setHostTimeZoneForTesting):
* Source/WTF/wtf/TimeZone.h: Added.
* Source/WTF/wtf/cocoa/TimeZoneCocoa.cpp: Added.
(WTF::timeZoneChangeNotification):
(WTF::listenForTimeZoneChangeNotifications):
* Source/WTF/wtf/glib/FilePathWatcher.cpp: Added.
(WTF::FilePathWatcher::FilePathWatcher):
(WTF::FilePathWatcher::~FilePathWatcher):
(WTF::FilePathWatcher::fileChangedCallback):
* Source/WTF/wtf/glib/FilePathWatcher.h: Added.
(WTF::FilePathWatcher::isActive const):
* Source/WTF/wtf/glib/TimeZoneGLib.cpp: Added.
(WTF::localtimeWatcher):
(WTF::timedate1Proxy):
(WTF::timedate1PropertiesChanged):
(WTF::onTimedate1ProxyReady):
(WTF::listenForTimeZoneChangeNotifications):
* Source/cmake/FindGLib.cmake:
* Tools/Scripts/run-gtk-tests:
* Tools/Scripts/run-timezone-glib-e2e-test: Added.
(find_testwtf):
(spawn_private_bus):
(own_timedate1):
(emit_timezone_changed):
(main):
* Tools/Scripts/run-wpe-tests:
* Tools/TestWebKitAPI/PlatformGTK.cmake:
* Tools/TestWebKitAPI/PlatformJSCOnly.cmake:
* Tools/TestWebKitAPI/PlatformWPE.cmake:
* Tools/TestWebKitAPI/Tests/WTF/glib/FilePathWatcher.cpp: Added.
(TestWebKitAPI::TEST(WTF_FilePathWatcher, FiresOnWrite)):
(TestWebKitAPI::TEST(WTF_FilePathWatcher, FiresOnSymlinkSwap)):
(TestWebKitAPI::TEST(WTF_FilePathWatcher, IgnoresUnrelatedSiblings)):
* Tools/TestWebKitAPI/Tests/WTF/glib/TimeZoneGLib.cpp: Added.
(TestWebKitAPI::WTF_TimeZoneGLib::SetUpTestSuite):
(TestWebKitAPI::WTF_TimeZoneGLib::TearDownTestSuite):
(TestWebKitAPI::TEST_F(WTF_TimeZoneGLib, FiresOnTimezonePropertyChange)):
(TestWebKitAPI::TEST_F(WTF_TimeZoneGLib, FiresOnInvalidatedTimezone)):
(TestWebKitAPI::TEST_F(WTF_TimeZoneGLib, IgnoresUnrelatedProperties)):
(TestWebKitAPI::TEST(WTF_TimeZoneGLib_External, ReceivesExternalSignal)):

Canonical link: https://commits.webkit.org/313750@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/Support-time-zone-change-notifications-on-linux branch from b439d1e to 11993c8 Compare May 22, 2026 19:47
@webkit-commit-queue
Copy link
Copy Markdown
Collaborator

Committed 313750@main (11993c8): https://commits.webkit.org/313750@main

Reviewed commits have been landed. Closing PR #64562 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 11993c8 into WebKit:main May 22, 2026
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants