Dubwise56 / Rimatomics

Nuclear power | Energy weapons | Nuclear weapons
41 stars 15 forks source link

D3D11 Error 80070057 in RimWorld 1.2, followed by crashes. #21

Closed N3X15 closed 3 years ago

N3X15 commented 3 years ago

I recently started having issues where I'd start a save and shortly after a pawn entered a map (either a trader or a raid), the game would just crash to desktop. Compounding the problem is the fact that it would leave no corresponding Player.log messages, only a Windows Event Log entry which, as you know, is completely useless on Unity.

Been debugging this for about a week, trying to figure out what was going on, but had trouble pinning down which mod caused it until today.

The root of the problem seems to be a fairly innocuous debug message during initial startup (BEFORE loading a save) about DirectX 11 failing to create a 2D texture. I did some googling, and it seems that error 80070057 is E_INVALIDARG, suggesting incorrect arguments are being fed to DX11.

d3d11: failed to create 2D texture id=9051 width=4 height=125 mips=8 dxgifmt=28 [D3D error was 80070057]

(Filename: C:\buildslave\unity\build\Runtime/GfxDevice/d3d11/TexturesD3D11.cpp Line: 496)

d3d11: failed to create 2D texture shader resource view id=9051 [D3D error was 80070057]

(Filename: C:\buildslave\unity\build\Runtime/GfxDevice/d3d11/TexturesD3D11.cpp Line: 460)

I did some experimentation with adding Debug.Log to the constructor of Texture2D in UnityEngine.CoreModule using dnSpy, so I could at least get a stacktrace of the offending calls, but it overwhelmed the logger. I ended up restoring the DLL to its original state and validating the game core files via steam.

So, I cleared my modlist and spent the last two or three days slowly adding mods back into it to see which one triggered the error.

RimAtomics drew the short straw. I confirmed it was the problem by restoring my original mod list, sans RimAtomics. The game runs without crashing, and doesn't present the error above.

tl;dr

Technical Info

Attempts at Mitigation

Not sure you'll be able to fix this, since it appears to be a Unity bug, but I can't really investigate further. Maybe you'll have better insights on this than I.

Dubwise56 commented 3 years ago

does it happen with rimatomics on its own?

looked through my files and the texture thats width=4 height=125 is Textures\Rimatomics\UI\ReactorUI\tempGaugeVert, its an old graphic that i dont use anymore in 1.2 but the texture file is still there for the old versions, you could try deleting that file and see if it still crashes but on a different texture, which would mean its something like a driver issue or running out of memory, or someone playing silly buggers with some harmony patching to graphics classes

N3X15 commented 3 years ago

Yeah, it's still causing the initial D3D11 issue. Haven't yet reached the point on my save where it just keels over and dies, but the D3D error kind of guarantees it eventually.

Player.log (with verbose)

Modlist is literally just:

[Mod list length: 4] Harmony [https://steamcommunity.com/sharedfiles/filedetails/?id=2009463077] Core [https:// no link (local mod)] Rimatomics [https://steamcommunity.com/sharedfiles/filedetails/?id=1127530465] Royalty [Official DLC] [https:// no link (local mod)]

Dubwise56 commented 3 years ago

so i just checked my log and i also have the d3d error for failed to create 2D texture, which means that's normal, everyone has it and probably unrelated to the crash, i just changed the size of the texture by a few pixels and the error stopped, i pushed it to the git master so you can copy that one in to clear that error and carry on searching for the cause, i haven't had anyone else report a crash like this before

N3X15 commented 3 years ago

All right, back to the hunt I guess. Thanks for looking into it.