Reset Hermes timezone cache on system timezone change#55467
Open
Im-awesome-Aadi wants to merge 1 commit intofacebook:mainfrom
Open
Reset Hermes timezone cache on system timezone change#55467Im-awesome-Aadi wants to merge 1 commit intofacebook:mainfrom
Im-awesome-Aadi wants to merge 1 commit intofacebook:mainfrom
Conversation
5e847ce to
f19553f
Compare
f19553f to
38b9ec3
Compare
…mezone change Summary: When the device timezone changes while the app is running, JavaScript Date still return the local time according to the previous timezone. This happens because Hermes caches timezone information to improve performance. If the device timezone changes during app runtime, local time calculations continue using the old cached timezone. Hermes provides a native API, resetTimezoneCache(), to reset this cached information. This PR adds an internal Android module that calls this API whenever the platform detects a timezone change. Changes: Kotlin: TimeZoneModule Listens for Intent.ACTION_TIMEZONE_CHANGED broadcasts Calls a JNI method to reset Hermes timezone cache Safely registers/unregisters the receiver during Catalyst lifecycle Open for unit testing C++: TimeZoneCache Provides resetNativeHermesTimeZoneCache() JNI method Calls hermes::IHermes::resetTimezoneCache() No-op if runtime pointer is null or runtime is not Hermes Test Plan: Java unit tests Verify broadcast receiver registration/unregistration Verify native reset hook is invoked on timezone change
38b9ec3 to
ed755dc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog: [Android] [Fixed] Reset Hermes timezone cache on system timezone change
Summary:
When the device timezone changes while the app is running, JavaScript Date still return the local time according to the previous timezone.
This happens because Hermes caches timezone information to improve performance. If the device timezone changes during app runtime, local time calculations continue using the old cached timezone.
Hermes provides a native API, resetTimezoneCache(), to reset this cached information. This PR adds an internal Android module that calls this API whenever the platform detects a timezone change.
Changes:
Kotlin: TimeZoneModule
Listens for Intent.ACTION_TIMEZONE_CHANGED broadcasts
Calls a JNI method to reset Hermes timezone cache
Safely registers/unregisters the receiver during Catalyst lifecycle
Open for unit testing
C++: TimeZoneCache
Provides resetNativeHermesTimeZoneCache() JNI method
Calls hermes::IHermes::resetTimezoneCache()
No-op if runtime pointer is null or runtime is not Hermes
Test Plan:
Java unit tests
Verify broadcast receiver registration/unregistration
Verify native reset hook is invoked on timezone change