Ryujinx
Ryujinx copied to clipboard
[Bug] Ryujinx automatically close after attempting to change the time
Description of the issue
Ryujinx does not allow me to change the time. When I try to change the time (hour and minutes), program closes/crashes. I would like to move the time around time when play ACNH so this is quite troublesome.
Reproduction steps
- Opened the setting
- At the System Time section, clicked hours and minutes part to change the time.
- Program immediately closes/crashs.
Log file
Ryujinx_1.1.1268_2024-04-08_18-19-19.log
OS
Windows 11
Ryujinx version
1.1.1268
Game version
Animal Crossing New Horizon 2.0.6
CPU
2th Gen Intel(R) Core(TM) i5-12500H 2.50 GHz
GPU
NVDIA GeForce RTX 3050 Ti
RAM
16.0 GB
List of applied mods
No response
Additional context?
No response
I can take this one.
Edit: It was difficult to replicate the issue. At first I changed time and had no issue. Changed date and time, no issue. Opened game changed date/time again, etc. No problems. Then after changing the time a few more times it would crash instantly every time, with the same error as posted above. The CurrentTime
TimeSpan was set to some nonsense value (-533.10:50:42.4570000).
I'm thinking what's the best way to resolve this. I may just check if CurrentTime
is not a valid TimeSpan and if so, default it to TimeSpan.Zero
(but that sort of just hides the real issue).
Edit x2: I narrowed it down. The issue occurs when you set the date back to a previous date. Doing that consistently throws the error.
Edit x3: I also noticed that changing the date doesn't even do anything. You can select to set it back in time (which throws the error) or select to set it ahead in time, but upon clicking 'Apply' and coming back to the tab, it remains at today's current date.
I've got a method created to reset the CurrentTime
to TimeSpan.Zero
if it's an invalid value, which prevents the app from crashing, but it's more of a cover up than a fix. This may be a bigger issue regarding the date not being set...
Should I assign it to you?
Should I assign it to you?
Leave it open for someone else. I don't think I'll have time to go in depth regarding the date issue as well. I may keep looking at it in the background if no one picks it up though (in which I'll comment here).
I have this exact same issue myself with changing the clock just crashes the program and another odd problem where changing the date/time doesn't actually save. Instead it reverts back to the date set to my PC rather set it to whatever I want. It keeps reverting to match my PC.
I think the bug is in SettingsViewModel.cs , this line stores the difference in seconds between the current system time and the configured time
config.System.SystemTimeOffset.Value = Convert.ToInt64((CurrentDate.ToUnixTimeSeconds() + CurrentTime.TotalSeconds) - DateTimeOffset.Now.ToUnixTimeSeconds());
That in and of itself sounds fine to me, when we go backwards in time it results in a large negative number
Then it loads that value here
DateTime currentDateTime = DateTime.Now;
CurrentDate = currentDateTime.Date;
CurrentTime = currentDateTime.TimeOfDay.Add(TimeSpan.FromSeconds(config.System.SystemTimeOffset));
Now here's the problem AIUI The date is always set to the current system time date, and then the time gets the entirety of the offset. This can result in a hilariously large negative time-within-the-day that crashes Avalonia's datetime picker
I think the fix is just checking if the absolute value of the offset is larger than a day when loading, if so substract from the CurrentDate instead, and use the remainder on the currentTime?
Changing the loading code to
DateTime currentHostDateTime = DateTime.Now;
TimeSpan SystemDateTimeOffset = TimeSpan.FromSeconds(config.System.SystemTimeOffset);
DateTime currentDateTime = currentHostDateTime.Add(SystemDateTimeOffset);
CurrentDate = currentDateTime.Date;
CurrentTime = currentDateTime.TimeOfDay;
Seems to fix it on my end (Only briefly tested it)