Skip to content

Conversation

@cobalt-github-releaser-bot
Copy link
Collaborator

Refer to the original PR: #8935

Adds a time zone monitor for Linux platforms using inotify. It observes
changes to system time zone configuration files such as /etc/localtime.
Upon detecting a modification, a kSbEventDateTimeConfigurationChanged
event is injected into the Starboard application event queue. This allows
Cobalt to dynamically react to system time zone updates without requiring
a restart, improving time-sensitive feature consistency.

Have to remove the time zone caching mechanism in starboard/shared/linux/time_zone_get_name.cc to redetermine time zone from system whenever SbTimeZoneGetName is called. Check the SbTimeZoneGetName implementation on ATV, ATV does not have the caching mechanism to determine the time zone only once either.

The TimeZoneMonitor class uses a inifinite blocking poll command to watch system time zone files, and non-blocking read command to read the time zone change to buffer to avoid read command hanging the thread, and a blocking write command to signal the destruction of TimeZoneMonitor.

Test: (on evergreen-x64)
Before this change: http://screencast/cast/NDc5OTQwMDc5MzYwNDA5Nnw1MjJlOWM1OC00Yg
After this change: http://screencast/cast/NTg2NDY3NDA0OTM5MjY0MHw4NmIwOThjZS0zMw
Bug: 448161236

Adds a time zone monitor for Linux platforms using inotify. It observes
changes to system time zone configuration files such as /etc/localtime.
Upon detecting a modification, a kSbEventDateTimeConfigurationChanged
event is injected into the Starboard application event queue. This
allows
Cobalt to dynamically react to system time zone updates without
requiring
a restart, improving time-sensitive feature consistency.

Have to remove the time zone caching mechanism in
`starboard/shared/linux/time_zone_get_name.cc` to redetermine time zone
from system whenever `SbTimeZoneGetName` is called. Check the
`SbTimeZoneGetName` implementation on ATV,
[ATV](https://source.corp.google.com/h/github/youtube/cobalt/+/main:starboard/android/shared/time_zone_get_name.cc;l=28?q=SbTimeZoneGetName&ss=h%2Fgithub%2Fyoutube%2Fcobalt%2F%2B%2Frefs%2Fheads%2Fmain)
does not have the caching mechanism to determine the time zone only once
either.

The TimeZoneMonitor class uses a inifinite blocking poll command to
watch system time zone files, and non-blocking read command to read the
time zone change to buffer to avoid read command hanging the thread, and
a blocking write command to signal the destruction of TimeZoneMonitor.

Test: (on evergreen-x64)
Before this change:
http://screencast/cast/NDc5OTQwMDc5MzYwNDA5Nnw1MjJlOWM1OC00Yg
After this change:
http://screencast/cast/NTg2NDY3NDA0OTM5MjY0MHw4NmIwOThjZS0zMw
Bug: 448161236

(cherry picked from commit 56b39bb)
@github-actions
Copy link

🤖 Gemini Suggested Commit Message


linux: Implement time zone monitor for Linux

This change introduces a TimeZoneMonitor class for Linux platforms. It uses
inotify to observe changes to system time zone configuration files like
/etc/localtime. When a modification is detected, a
kSbEventDateTimeConfigurationChanged event is injected into the Starboard
application event queue.

This enables Cobalt to dynamically react to system time zone updates
without requiring an application restart, thereby improving consistency
for time-sensitive features. Additionally, the time zone caching
mechanism in SbTimeZoneGetName has been removed to ensure the system's
current time zone is always re-determined upon query.

Bug: 448161236

💡 Pro Tips for a Better Commit Message:

  1. Influence the Result: Want to change the output? You can write custom prompts or instructions directly in the Pull Request description. The model uses that text to generate the message.
  2. Re-run the Generator: Post a comment with: /generate-commit-message

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request cherry-picks the implementation of a time zone monitor for Linux. The changes correctly introduce the TimeZoneMonitor to watch for system time zone file modifications and inject an event upon detection. The removal of the time zone caching in SbTimeZoneGetName is also correctly implemented to allow for dynamic updates.

While reviewing the implementation, I found an opportunity to improve the robustness of the TimeZoneMonitor by handling inotify queue overflows. This is an edge case, but handling it would make the monitor more resilient. Please see the specific comment for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants