Jorixon / JASM

Just Another Skin Manager
GNU General Public License v3.0
148 stars 16 forks source link

'0x00' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0. #181

Closed its-x3non closed 5 months ago

its-x3non commented 5 months ago

Describe the bug JASM Crashes after importing from character mod rar and backing out to character screen.

To Reproduce Steps to reproduce the behavior:

  1. Go to any character, in my case, I want to add a Lumine mod
  2. Drag and drop mod, in my example, this mod
  3. Add Mod (auto importing the GameBanana info results in same crash)
  4. Back out to character screen
  5. Crash
  6. See error

Stack Trace

System.Text.Json.JsonException: '0x00' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
 ---> System.Text.Json.JsonReaderException: '0x00' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0.
   at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
   at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker)
   at System.Text.Json.Utf8JsonReader.ReadFirstToken(Byte first)
   at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
   at System.Text.Json.Utf8JsonReader.Read()
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   --- End of inner exception stack trace ---
   at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.ContinueDeserialize(ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.DeserializeAsync(Stream utf8Json, CancellationToken cancellationToken)
   at GIMI_ModManager.WinUI.Services.Notifications.ModNotificationManager.InitializeAsync()
   at GIMI_ModManager.WinUI.Services.Notifications.ModNotificationManager.InitializeAsync()
   at GIMI_ModManager.WinUI.Services.Notifications.ModNotificationManager.GetNotificationsForModAsync(Guid modId, NotificationType type)
   at GIMI_ModManager.WinUI.ViewModels.CharactersViewModel.RefreshNotificationsAsync()
   at GIMI_ModManager.WinUI.ViewModels.CharactersViewModel.OnNavigatedTo(Object parameter)
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
   at Microsoft.UI.Dispatching.DispatcherQueueSynchronizationContext.<>c__DisplayClass2_0.<Post>b__0()

Inner Exception Stack Trace

System.Text.Json.JsonReaderException: '0x00' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0.
   at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
   at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker)
   at System.Text.Json.Utf8JsonReader.ReadFirstToken(Byte first)
   at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
   at System.Text.Json.Utf8JsonReader.Read()
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)

Expected behavior I expected to go back to the character mod screen without any problem or crash.

Screenshots Here is an imgur for the gifs of my problem if I didn't explain it thoroughly.

Desktop (please complete the following information):

Additional context

  1. I'm able to access any other tab, but once I press the character mod tab, the program crashes (shown in crash instance 1)
  2. The program also crashes if I try to drag and drop the folder inside of said character's mod folder (shown in crash instance 2)
  3. The problem is gone once the mod is deleted (shown in crash instance 2)
  4. Mods still work in-game, program just crashes when trying to open after importing
Jorixon commented 5 months ago

Hmmm, A quick fix, if you don't mind wiping your JASM settings, is to delete the settings folder at: %localAppData%\JASM (C:\Users\<username>\AppData\Local\JASM). If this does not fix it the problem is likely more fundamental.

I'll see if I can add some error handling in the next release, so it at least doesn't crash the app.

Guessing from the stack trace and error that maybe the file that stores the notifications has gotten corrupted/malformed somehow...

its-x3non commented 5 months ago

This fix worked! Thank you so much. I should have most likely submitted this earlier as it started happening when I updated from an older version to a newer version. I don't quite remember which version though as it was quite a while. I might have been updating from a v1.x version to a v2.x version.

Thank you again though, this has fixed my problem!