Unity full build crashes when using dynamic meshes

2019-09-14 12:34发布

I'm working on a Unity project which runs without issue from within the Editor. However I've gone to test a full Windows desktop build today (having not done one in a while, sadly) and I get a crash to desktop.

The Menu and Loading scenes work without issue. The crash happens after I start a new game - the initial frame of the game scene is shown, and the crash happens immediately after.

I'm trying to find the source of the problem now. I'm running as a development build, and I'm checking through the crash dump logs it generates each time.

The error log says:

Read from location 00000175 caused an access violation.

And the output_log.txt contains a load of stuff that all looks ok, and then suddenly:

Crash!!!
SymInit: Symbol-SearchPath: '.;F:\Projects\Code\Unity\Pub Demo;F:\Projects\Code\Unity\Pub Demo\Build;C:\WINDOWS;C:\WINDOWS\system32;SRV*C:\websymbols*http://msdl.microsoft.com/download/symbols;', symOptions: 530, UserName: 'Octopoid'
OS-Version: 10.0.10586 () 0x100-0x1
F:\Projects\Code\Unity\Pub Demo\Build\Pub Demo.exe:Pub Demo.exe (00007FF7AAE80000), size: 25665536 (result: 0), SymType: 'PDB', PDB: 'F:\Projects\Code\Unity\Pub Demo\Build\player_win_development_x64.pdb', fileVersion: 5.3.3.3441

(N.B. The crash logs are fairly large so I've refrained from posting them all - please let me know if any other part of them would help.)

I've tried added a Debug.Log into a couple of places and it would appear that everything is awaking and starting without issue, and the update loop is going around twice before this happens.

However, the project is fairly sizable and I have no idea where to start looking for the issue - I really hope there's a better way than adding a Debug.Log into EVERY Awake/Start/Update/etc.

  • Unity 5.3.3 f1 Personal
  • Windows 10 Pro (1511)

How can I find the cause of the crash?

标签: unity3d crash
1条回答
老娘就宠你
2楼-- · 2019-09-14 13:34

After much painful testing and confusion, the solution was in the end extremely simple. One of my scripts is generating a procedural mesh. As per the documentation I was calling MarkDynamic() on the mesh:

this.mesh.MarkDynamic();

Having done this, setting the mesh.vertices property causes the build to crash immediately without any specific error messages or logs.

Whatever this function does under the hood, the problem only seems to affect the build, not the editor.

I've tried making the call just after instancing, just before setting the vertices, when using Clear() or not - whatever I tried, MarkDynamic() just seems to make the build crash for me.

The fix I've applied is simply to remove this call - performance seems to be exactly the same as in the editor.


Many thanks to @Programmer for all your help finding this issue!

查看更多
登录 后发表回答