Yellow-Dog-Man / Resonite-Issues

Issue repository for Resonite.
https://resonite.com
139 stars 2 forks source link

In Headless, `System.AccessViolationException` is Thrown in BepuPhysics That Crashes Headless #1198

Closed stiefeljackal closed 9 months ago

stiefeljackal commented 9 months ago

Describe the bug?

When testing on the Windows version of the Headless server, a System.AccessViolationException was thrown after a few minutes of being up when hosting a specific world. The world that was used to test this is Creator Jam 236 - Livin' in the Present (resrec:///G-Creator-Jam/R-b900a673-451a-4ddf-b600-698555e7211f)

To Reproduce

  1. Start up the Headless with loadWorldURL in the config set to "resrec:///G-Creator-Jam/R-b900a673-451a-4ddf-b600-698555e7211f".
  2. Wait for a few minutes to witness the exception thrown.

Expected behavior

The Headless server on Windows should be able to host the world without crashing the entire server.

Screenshots

image

Resonite Version Number

2024.1.19.687

What Platforms does this occur on?

Windows

What headset if any do you use?

Headless

Log Files

JACKAL_MK2 - 2024.1.19.687 - 2024-01-19 15_25_09.log

Additional Context

This appears to only happen on the Windows version of the Headless server as I was unable to reproduce this in the Linux version.

resheadless - 2024.1.19.687 - 2024-01-19 15_12_17.log

Reporters

StiefelJackal

shiftyscales commented 9 months ago

Can you please isolate the replication object that is causing the issue in that world, and transplant the problematic object into a gridspace to confirm, @stiefeljackal?

Based on the snippet of the console output- it sounds like it may be a corrupted/malformed convex hull collider that is causing issues.

stiefeljackal commented 9 months ago

@shiftyscales That was my thought as well based on the log reporting attempts for a mesh variant that cannot be found.

I will look for the object and attempt to load it into a gridspace.

shiftyscales commented 9 months ago

Any update on this issue, @stiefeljackal?

stiefeljackal commented 9 months ago

@shiftyscales I do have an update on this. I will post my findings tonight or tomorrow morning once I reverify.

I apologize for the delay and the lack of a response on my end; the past few days were super busy.

stiefeljackal commented 9 months ago

@shiftyscales As promised, I have produced a world that has separated out the item that is causing the Headless for Windows to crash. The RecordId provided below should be the direct world RecordId.

Record: resrec:///U-StiefelJackal/R-bb9237dd-0768-4c8f-a823-b5c431632dc4

I have started the world with Headless for Windows and have experienced the same exception being thrown.

Windows Log: JACKAL_MK2 - 2024.1.29.1304 - 2024-01-30 04_18_36 - R-bb9237dd-0768-4c8f-a823-b5c431632dc4.log

However, this is not due to corruption as this does not occur on Headless for Linux.

Linux Log: resheadless - 2024.1.29.1304 - 2024-01-30 04_32_11 - R-bb9237dd-0768-4c8f-a823-b5c431632dc4.log

Based on my findings, a FrooxEngine.ConvexHullMesh does not reference an external mesh file, but generates the mesh based on the Points field under the component. You cannot see these points in the client since an Insepcter element does not exist for that field. However, you can see this information when you decompress the brson file.

With a System.AccessViolationException, this exception usually occurs when unmanaged code is utilized. Since YDMS is currently using a forked version of BepuPhysics (2.4.0.2-ydm-0.1.3), I cloned the specific commit (https://github.com/Yellow-Dog-Man/bepuphysics2/commit/d8e0d3a55dfe31cf7a32162e015522be74670d05) that contains this same verison number, built the project under Release, and used the produced Bepu DLLs. As a result, same issue occurs. Afterwards, I built the project under Debug and used those produced Bepu DLLs files. Based on that test, the Headless Server did not crash and kept the session up when hosting the world.

I started isolating the Bepu DLLs until I found BepuUtilities.dll to be causing this exception. Using the provided/downloaded dll will cause the exception to throw and crash the server, but using the DLL compiled under Debug did not produce any issues. I am leaning towards an issue with BepuUtilities.dll as the commit (https://github.com/Yellow-Dog-Man/bepuphysics2/commit/d8e0d3a55dfe31cf7a32162e015522be74670d05) introduced additional logic for convex hulls and introduced methods within BepuUtilities.dll that touch unmanaged code.

BepuUtilities Built in Debug - Log: JACKAL_MK2 - 2024.1.29.1304 - 2024-01-30 05_52_57 - BepuUtilities [Debug Build].log

BepuUtilities Build in Release - Log: JACKAL_MK2 - 2024.1.29.1304 - 2024-01-30 06_00_47 - BepuUtilities [Release Build].log

shiftyscales commented 9 months ago

Thanks for looking into this. This issue seems like it should have everything it needs, @Frooxius.

Frooxius commented 9 months ago

Thanks for the info!

I've backported fix from BepuPhysicsV2 which seems to rework the convex hull a bit and this seems to have fixed this in 2024.2.2.906

I'm closing this. If you still run into this, we can reopen.

stiefeljackal commented 9 months ago

Tested and verified the fix. Thank you for your work! :)