-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bad Process.StartTime in .NET 6 on Android #67583
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to this area: @dotnet/area-system-diagnostics-process Issue DetailsDescription
Reproduction Steps
Expected behaviorReturns the correct DateTime Actual behavior
Regression?No response Known WorkaroundsNo response ConfigurationNo response Other informationThis is the compiled apk files
|
@am11 Do you think you'll have time to fix this? |
@steveisok, thanks for the ping. #67589 needs device testing on Android. I tried to setup an emulator last month, but it was having some issues and I got distracted by other stuff. Is there any readymade docker or emulator setup available which I can pull and use without spending time on environment setup? Otherwise, if someone has the dev device and spare cycles to help, we need to debug this (standalone) C code and compare with Linux desktop to find out which API behaves differently on Android, and what is the minimal change that could be applied to it to get the ball rolling: #include <assert.h>
#include <stdio.h>
#include <time.h>
#include <inttypes.h>
#define TARGET_LINUX
enum
{
MicroSecondsToNanoSeconds = 1000, // 10^3
SecondsToNanoSeconds = 1000000000, // 10^9
SecondsToTicks = 10000000, // 10^7
TicksToNanoSeconds = 100, // 10^2
};
int64_t SystemNative_GetBootTimeTicks()
{
#ifdef TARGET_LINUX
struct timespec ts;
int result = clock_gettime(CLOCK_BOOTTIME, &ts);
assert(result == 0); // only possible errors are if the given clockId isn't supported or &ts is an invalid address
(void)result; // suppress unused parameter warning in release builds
int64_t sinceBootTicks = (ts.tv_sec * SecondsToTicks) + (ts.tv_nsec / TicksToNanoSeconds);
result = clock_gettime(CLOCK_REALTIME_COARSE, &ts);
assert(result == 0);
int64_t sinceEpochTicks = (ts.tv_sec * SecondsToTicks) + (ts.tv_nsec / TicksToNanoSeconds);
return sinceEpochTicks - sinceBootTicks;
#else
return -1;
#endif
}
int main() {
printf("%" PRId64 "\n", SystemNative_GetBootTimeTicks());
return 0;
} ( |
@steveisok is there any chance you could help @am11 with the Android debugging? |
Sorry, yes, we can help with this one. |
@simonrozsival can you please help out with this one? |
@am11 I tested the code on my device with API 32 and on emulators with API 21 and 24 and it worked well on all of these levels. It seems to me that the only problem with the PR is that you're checking |
@simonrozsival thank you for your help! |
Description
System.Diagnostics.Process.StartTime
throws an exception on net6.0-android, but works fine on Xamarin.AndroidReproduction Steps
https://github.com/BeyondDimension/AspNetCore.Mobile/blob/refs/tags/test-process-starttime/src/AspNetCore.Mobile.Droid/MainActivity.cs#L50-L63
Expected behavior
Returns the correct DateTime
Actual behavior
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
This is the compiled apk files
Xamarin.Android 12 APK
NET 6.0 APK
The text was updated successfully, but these errors were encountered: