Getting NullReferenceException When Building to Android and Using Immediate Mode Drawing

Avatar
  • updated

Whenever I load a scene where I am doing Immediate Mode Drawing after building to Android, using

using (Draw.Command(cam))

I get the following runtime error (I have Compatibility Mode disabled.):

2024/12/11 21:31:22.985 24901 25004 Error Unity NullReferenceException: Object reference not set to an instance of an object.
2024/12/11 21:31:22.985 24901 25004 Error Unity at UnityEngine.Rendering.RenderGraphModule.RenderGraphResourceRegistry.GetRenderTargetInfo (UnityEngine.Rendering.RenderGraphModule.ResourceHandle& res, UnityEngine.Rendering.RenderGraphModule.RenderTargetInfo& outInfo) [0x00000] in <00000000000000000000000000000000>:0
2024/12/11 21:31:22.985 24901 25004 Error Unity at UnityEngine.Rendering.RenderGraphModule.RenderGraphBuilders.CheckUseFragment (UnityEngine.Rendering.RenderGraphModule.TextureHandle tex, System.Boolean isDepth) [0x00000] in <00000000000000000000000000000000>:0
2024/12/11 21:31:22.985 24901 25004 Error Unity at UnityEngine.Rendering.RenderGraphModule.RenderGraphBuilders.SetRenderAttachment (UnityEngine.Rendering.RenderGraphModule.TextureHandle tex, System.Int32 index, UnityEngine.Rendering.RenderGraphModule.AccessFlags flags, System.Int32 mipLevel, System.Int32 depthSlice) [0x00000] in <00000000000000000000000000000000>:0
2024/12/11 21:31:22.985 24901 25004 Error Unity at Shapes.ShapesRenderPass.RecordRenderGraph (UnityEngine.Rendering.RenderGraphModule.RenderGraph renderGraph, UnityEngine.Renderi


If I disable the script that is using immediate mode drawing, the errors disappear.

Reporting a bug? please specify Unity version:
6000.0.30
Reporting a bug? please specify Shapes version:
4.5.0
Reporting a bug? please specify Render Pipeline:
URP
Avatar
Justin Wasilenko

While I am not getting that error, I get this message instead:

12-12 16:22:26.214 5757 5879 W Unity : VULKAN: GENERAL WARNING: The following warning was triggered: VKDBGUTILWARN003. Please refer to the Adreno Game Developer Guide for more information: https://developer.qualcomm.com/sites/default/files/docs/adreno-gpu/snapdragon-game-toolkit/learn_guides.html
12-12 16:22:26.214 5757 5879 W Unity : Objects:
12-12 16:22:26.214 5757 5879 W Unity : #0: { name = ExecuteRenderGraph (C0:C/XR, DS:C/X), type = VK_OBJECT_TYPE_RENDER_PASS, handle = 0xb40000722220dd00 }
12-12 16:22:26.214 5757 5879 W Unity :


Same Unity, Shapes, and URP version as the above. Using Quest 3 and Vulkan.


In my case, adding some Shape game objects to the scene they render just fine. However if I override DrawShapes(Camera cam) for Immediate mode (which I use extensively in my project) nothing gets rendered at all, just a black screen, and the above Vulkan warning being spammed in ADB. Even just doing a simple override like this will cause the black screen and nothing being rendered:


public override void DrawShapes(Camera cam) { using (Draw.Command(cam)) { // Nothing here } }

Avatar
Justin Wasilenko

Also wanted to add, I had no problems on Unity 2022 and the previous version of Shapes with Immediate drawing on Quest.

Avatar
Justin Wasilenko

I keep trying to find out what has gone wrong with Shapes as it's necessary for my game. Today I was at least able to get an error from the adb logs on Quest:

AndroidPlayer "Oculus_Quest 3@ADB:2G0YC6LF6000D1:0" A non-multisampled texture being bound to a multisampled sampler. Disabling in order to avoid undefined behavior. Please enable the bindMS flag on the texture. UnityEngine.Rendering.Universal.UniversalRenderPipeline:RenderSingleCamera(ScriptableRenderContext, UniversalCameraData) UnityEngine.Rendering.Universal.UniversalRenderPipeline:RenderCameraStack(ScriptableRenderContext, Camera) UnityEngine.Rendering.Universal.UniversalRenderPipeline:Render(ScriptableRenderContext, List`1) UnityEngine.Rendering.RenderPipelineManager:DoRenderLoop_Internal(RenderPipelineAsset, IntPtr, Object) [./Runtime/Shaders/ShaderImpl/ShaderTextureProperty.cpp line 496775000]

This error repeats itself every frame.