Norbyte / bg3se

Baldur's Gate 3 Script Extender
Other
1.15k stars 67 forks source link

Debugger occasionally crashes with Sequence Number Mismatch #468

Open osirisOfGit opened 1 month ago

osirisOfGit commented 1 month ago

I have attempted solutions to common problems

Yes

I have checked that my game version is supported

Yes

OS

Windows 10

Platform

GOG

Description

While using the Lua debugger and reloading saves frequently, the debugger will crash with:

System.IO.InvalidDataException: NSE sequence number mismatch; got {x} expected {x - 1}

actual message is:

System.IO.InvalidDataException: NSE sequence number mismatch; got 6969 expected 6968
   at NSE.DebuggerFrontend.DebuggerClient.MessageReceived(BackendToDebugger message)
   at NSE.DebuggerFrontend.AsyncProtobufClient.RunLoop()
   at NSE.DebuggerFrontend.DAPMessageHandler.DebugThreadMain()

but the sequence number changes each time

This happens when using no mods, using a couple mods, and using a lot of mods.

This happens with Steam and GOG version

Indications

Happens exclusively when running the Lua Debugger, and the exception details that it's NSE (presumably Norbyte's Script Extender)

Diagnostic Files

BG3 Diagnostic Data.txt

Steps to Reproduce

  1. Install latest Debugger artifacts and extension per https://github.com/Norbyte/bg3se/blob/main/Docs/Debugger.md
  2. Start a game through VSCode, allowing the Debugger to hook up
  3. Load into a save
  4. Quick-load that save a bunch of times. Eventually it will crash - how long it takes varies significantly. Sometimes it happens every 3 loads, sometimes every 10-15

Expected Behavior

Not crashing

Actual Behavior

Game crashes completely

osirisOfGit commented 1 month ago

Additional note - the more time i wait between loads (like, 5+ minutes it looks like), the less likely it is that this behavior occurs (also, i'm loading saves frequently because i'm dealing with a situation where reset doesn't help me, e.g. testing behavior on entering combat)

osirisOfGit commented 1 month ago

Partial correction - the debugger crash doesn't make the game crash, it was just triggering the postDebugTask in my VSCode launch.json and shutting down BG3. Commenting that out lets the debugger crash in isolation, allowing me to reconnect it to the game after

Norbyte commented 1 month ago

This is a known issue that usually happens when the client/server concurrently send updates through the DAP; a fix is planned but since it requires a rework of the networking logic I'm not sure when it will be done.