Repository navigation
[release/11.0.1xx][NativeAOT] Initialize the device startup time zone offset - #13365
Open
simonrozsival wants to merge 2 commits into
Open
simonrozsival wants to merge 2 commits into
simonrozsival wants to merge 2 commits into
Conversation
Context: #13359 Context: #13357 NativeAOT did not initialize System.TimeZoneInfo.LocalDateTimeOffset, leaving the first DateTimeOffset.Now call without the runtime startup-offset fast path. The value must reflect the Android device at process startup rather than a build-time host setting. Pass the device offset from NativeAotRuntimeProvider through the Java init declaration to the managed UCO, and publish its invariant string before managed JNI runtime creation or application registration. Preserve the release branch XA_Host_NativeAOT_OnInit call and add the NativeAOT device-offset regression test. The NativeAOT_OnInit C ABI remains unchanged. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the NativeAOT device UTC-offset startup change.
No open issues 🎉
What changed in this PR
Backports #13359 to release/11.0.1xx, enabling NativeAOT’s DateTimeOffset.Now startup fast path using the Android device’s UTC offset rather than the build host’s time zone.
Changes:
- Compute the device offset, including daylight saving time, with support for pre-API-26 devices.
- Pass the offset through Java/JNI and publish it before managed runtime creation, preserving the existing host initialization call and C ABI.
- Add a NativeAOT regression test checking the startup value and
DateTimeOffset.Now.Offsetagainst the device.
| File | Description |
|---|---|
| tests/Mono.Android-Tests/Mono.Android-Tests/System/TimeZoneTest.cs | Adds device-offset regression coverage for NativeAOT. |
| src/Xamarin.Android.Build.Tasks/Resources/NativeAotRuntimeProvider.java | Computes and forwards the device’s startup UTC offset. |
| src/Xamarin.Android.Build.Tasks/Resources/JavaInteropRuntime.java | Adds the offset parameter to the native initialization declaration. |
| src/Microsoft.Android.Runtime.NativeAOT/Android.Runtime.NativeAOT/JavaInteropRuntime.cs | Receives the offset and publishes its invariant string through AppContext. |
Review effort: Balanced
This branch has not been deployed
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.
Backport of dotnet/android#13359 to
release/11.0.1xx.Context: dotnet/android#13357
NativeAOT does not initialize
System.TimeZoneInfo.LocalDateTimeOffset, leaving the firstDateTimeOffset.Nowcall without the runtime startup-offset fast path. The offset must reflect the Android device at process startup.Pass the offset computed by
NativeAotRuntimeProviderthrough the Java init declaration to the matching managed UCO, then publish its invariant string before managed JNI runtime creation or application registration. Preserve the release branch'sXA_Host_NativeAOT_OnInitcall and leave theNativeAOT_OnInitC ABI unchanged. Add theNativeAotStartupOffsetMatchesDeviceregression test.Validation ran with process-local
TZ=Pacific/Honolulu, workspace-local SDK/toolchain/NuGet/Gradle directories,CCACHE_DISABLE=1on the successful retry, and emulatoremulator-5554at API 35 / arm64-v8a.make prepare CONFIGURATION=Release— passed; installed SDK 11.0.100-rtm.26524.110.make leeroy CONFIGURATION=Release— passed on retry; ILCompiler and NativeAOT runtime pack resolved to 11.0.0. One workload warning reported thattools/workload-dependencieshas no commit metadata. The first attempt failed because the isolatedNUGET_PACKAGESpath lacked a trailing slash; retry corrected it../dotnet-local.sh build -t:Install -c Release tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj -p:TestsFlavor=NativeAOT -p:PublishAot=true -p:RuntimeIdentifier=android-arm64 -p:AndroidSupportedAbis=arm64-v8a -p:IncludeCategories=NativeAOTTimeZone— passed and installed the arm64 test package. The build emitted NativeAOT trim/AOT analysis warnings and XA0036 becauseAndroidSupportedAbisis deprecated; the selectedRuntimeIdentifierwasandroid-arm64.(cd tests/Mono.Android-Tests/Mono.Android-Tests && ../../../dotnet-local.sh test Mono.Android.NET-Tests.csproj --no-build -c Release --device emulator-5554 --report-trx --results-directory ../../../bin/TestRelease/TestResults -p:TestsFlavor=NativeAOT -p:PublishAot=true -p:RuntimeIdentifier=android-arm64 -p:IncludeCategories=NativeAOTTimeZone)— passed, 1/1 (NativeAotStartupOffsetMatchesDevice). The installed APK base/split code hashes matched the final AAB.