- kristoffer
- Posts: 13
- Joined:
Unity error exit code after rendering View to RenderTexture
Hello!
Windows 11, Unity 2022.3.25 and Noesis 3.2.3
I have code pretty much identical to NoesisXamlEditor.RenderPreview(...).
When that code runs I get the correct result in the produced RenderTexture but it seems to leave Unity in a strange state because after this, when Unity exits, the return code is -1073741819.
And since I'm checking the exit code after automated tests this causes a problem.
It seems to be when Graphics.ExecuteCommandBuffer(_commands) runs that the problem occurs, so I'm thinking something goes wrong in the rendering part of Unity, which I know very little about. No errors are logged in the regular Unity log, perhaps there is a way to dig deeper into the rendering mechanism?
To be clear this all about the Unity Editor and not about any built artifacts, which is not relevant for my case.
Thanks for any input on the subject.
Windows 11, Unity 2022.3.25 and Noesis 3.2.3
I have code pretty much identical to NoesisXamlEditor.RenderPreview(...).
When that code runs I get the correct result in the produced RenderTexture but it seems to leave Unity in a strange state because after this, when Unity exits, the return code is -1073741819.
And since I'm checking the exit code after automated tests this causes a problem.
It seems to be when Graphics.ExecuteCommandBuffer(_commands) runs that the problem occurs, so I'm thinking something goes wrong in the rendering part of Unity, which I know very little about. No errors are logged in the regular Unity log, perhaps there is a way to dig deeper into the rendering mechanism?
To be clear this all about the Unity Editor and not about any built artifacts, which is not relevant for my case.
Thanks for any input on the subject.
- kristoffer
- Posts: 13
- Joined:
Re: Unity error exit code after rendering View to RenderTexture
Seems the error code sometimes can be -1073740791 also, depending on the View sent in.
Re: Unity error exit code after rendering View to RenderTexture
Are you getting this problem in both D3D11 and D3D12 renderers? Just commenting the Graphics.ExecuteCommandBuffer line fixes the issue? Could you please paste the relevant code here?
- kristoffer
- Posts: 13
- Joined:
Re: Unity error exit code after rendering View to RenderTexture
I think I've figured it out.
The code used to look like this
Adding a call to
just before the call to
resolved the issue.
This leads me to believe that you have the same issue in NoesisXamlEditor.RenderPreview(...) where NoesisRenderer.RenderOnscreen(...) is called before hitting NoesisRenderer.UnregisterView(...).
The code used to look like this
Code: Select all
private RenderTexture RenderPreview(View view, int width, int height)
{
if (view?.Content == null)
return null;
try
{
NoesisRenderer.SetRenderSettings();
view.SetSize(width, height);
view.Update(0.0);
NoesisRenderer.RegisterView(view, _commands);
NoesisRenderer.UpdateRenderTree(view, _commands);
NoesisRenderer.RenderOffscreen(view, _commands, false);
var rt = RenderTexture.GetTemporary(width, height, 24, RenderTextureFormat.Default, RenderTextureReadWrite.Default, 8);
_commands.SetRenderTarget(rt);
_commands.ClearRenderTarget(true, true, UnityEngine.Color.clear, 0.0f);
NoesisRenderer.RenderOnscreen(view, false, _commands, true);
UnityEngine.Graphics.ExecuteCommandBuffer(_commands);
_commands.Clear();
RenderTexture.ReleaseTemporary(rt);
return rt;
}
catch (System.Exception e)
{
Debug.LogException(e);
}
return null;
}
Code: Select all
NoesisRenderer.UnregisterView(view, _commands)
Code: Select all
UnityEngine.Graphics.ExecuteCommandBuffer(_commands)
This leads me to believe that you have the same issue in NoesisXamlEditor.RenderPreview(...) where NoesisRenderer.RenderOnscreen(...) is called before hitting NoesisRenderer.UnregisterView(...).
Re: Unity error exit code after rendering View to RenderTexture
I am not sure your fix makes sense. For example, NoesisXamlEditor is already unregistering views in OnDisable() method.
Unregistering a view before rendering with it seems suspicious to me.
Unregistering a view before rendering with it seems suspicious to me.
- kristoffer
- Posts: 13
- Joined:
Re: Unity error exit code after rendering View to RenderTexture
Sure, but in NoesisXamlEditor the view is unregistered after ExecuteCommandBuffer(...), which appears to have been causing issues for me (in my own implementation above at least).
Again, I don't know a whole lot of how rendering works so I'm not saying this is the right solution to the problem, but it worked like a charm.
I too thought unregistering before rendering seemed strange, and the only reason I tried was on a whim that since the _commands field is passed into UnregisterView(...) it maybe queues up additional commands for that unregistering action and since, I assumed, _commands is executed in ExecuteCommandBuffer(...) I thought it could make sense to fully populate it before sending it off.
Again, I don't know a whole lot of how rendering works so I'm not saying this is the right solution to the problem, but it worked like a charm.
I too thought unregistering before rendering seemed strange, and the only reason I tried was on a whim that since the _commands field is passed into UnregisterView(...) it maybe queues up additional commands for that unregistering action and since, I assumed, _commands is executed in ExecuteCommandBuffer(...) I thought it could make sense to fully populate it before sending it off.
Re: Unity error exit code after rendering View to RenderTexture
Could you please create a ticket about this? I will find time to investigate what's going on.
Who is online
Users browsing this forum: Ahrefs [Bot] and 4 guests