Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug NullReferenceException in GraphicRaycaster.Raycast

Discussion in 'UGUI & TextMesh Pro' started by ctortman, Feb 11, 2021.

  1. ctortman

    ctortman

    Joined:
    Feb 7, 2014
    Posts:
    1
    While running a standalone build, the internal GraphicRaycaster.Raycast will occasionally begin spamming NullReferenceExceptions related to mouse input every frame. This effectively shuts down the UI EventSystem, and makes it impossible to interact with the game. It occurs rarely enough to be difficult to reproduce, but often enough to be a significant problem (we've noticed about 3% of our users experiencing the error in recent beta tests). There's no common behavior associated with consistently producing the error, and as it's engine's code we can't debug it further. We've noticed two similar but slightly distinct stack traces when experiencing this problem:

    1)
    UnityEngine.UI.GraphicRaycaster.Raycast (UnityEngine.Canvas canvas, UnityEngine.Camera eventCamera, UnityEngine.Vector2 pointerPosition, System.Collections.Generic.IList`1[T] foundGraphics, System.Collections.Generic.List`1[T] results) (at <0b05dff53c1b4e478fedc6053f8a30c9>:0)
    UnityEngine.UI.GraphicRaycaster.Raycast (UnityEngine.EventSystems.PointerEventData eventData, System.Collections.Generic.List`1[T] resultAppendList) (at <0b05dff53c1b4e478fedc6053f8a30c9>:0)
    UnityEngine.EventSystems.EventSystem.RaycastAll (UnityEngine.EventSystems.PointerEventData eventData, System.Collections.Generic.List`1[T] raycastResults) (at <0b05dff53c1b4e478fedc6053f8a30c9>:0)
    UnityEngine.EventSystems.PointerInputModule.GetMousePointerEventData (System.Int32 id) (at <0b05dff53c1b4e478fedc6053f8a30c9>:0)
    UnityEngine.EventSystems.StandaloneInputModule.ProcessMouseEvent (System.Int32 id) (at <0b05dff53c1b4e478fedc6053f8a30c9>:0)
    UnityEngine.EventSystems.StandaloneInputModule.ProcessMouseEvent () (at <0b05dff53c1b4e478fedc6053f8a30c9>:0)
    UnityEngine.EventSystems.StandaloneInputModule.Process () (at <0b05dff53c1b4e478fedc6053f8a30c9>:0)
    UnityEngine.EventSystems.EventSystem.Update () (at <0b05dff53c1b4e478fedc6053f8a30c9>:0)

    2)
    UnityEngine.Component.GetComponent[T] () (at <047294ce45cf4b9a9441e48d2b8435e4>:0)
    UnityEngine.UI.Graphic.get_canvasRenderer () (at <0b05dff53c1b4e478fedc6053f8a30c9>:0)
    UnityEngine.UI.GraphicRaycaster.Raycast (UnityEngine.Canvas canvas, UnityEngine.Camera eventCamera, UnityEngine.Vector2 pointerPosition, System.Collections.Generic.IList`1[T] foundGraphics, System.Collections.Generic.List`1[T] results) (at <0b05dff53c1b4e478fedc6053f8a30c9>:0)
    UnityEngine.UI.GraphicRaycaster.Raycast (UnityEngine.EventSystems.PointerEventData eventData, System.Collections.Generic.List`1[T] resultAppendList) (at <0b05dff53c1b4e478fedc6053f8a30c9>:0)
    UnityEngine.EventSystems.EventSystem.RaycastAll (UnityEngine.EventSystems.PointerEventData eventData, System.Collections.Generic.List`1[T] raycastResults) (at <0b05dff53c1b4e478fedc6053f8a30c9>:0)
    UnityEngine.EventSystems.PointerInputModule.GetMousePointerEventData (System.Int32 id) (at <0b05dff53c1b4e478fedc6053f8a30c9>:0)
    UnityEngine.EventSystems.StandaloneInputModule.ProcessMouseEvent (System.Int32 id) (at <0b05dff53c1b4e478fedc6053f8a30c9>:0)
    UnityEngine.EventSystems.StandaloneInputModule.ProcessMouseEvent () (at <0b05dff53c1b4e478fedc6053f8a30c9>:0)
    UnityEngine.EventSystems.StandaloneInputModule.Process () (at <0b05dff53c1b4e478fedc6053f8a30c9>:0)
    UnityEngine.EventSystems.EventSystem.Update () (at <0b05dff53c1b4e478fedc6053f8a30c9>:0)

    Anyone else ran into this problem and found a way to work around it (or even just to consistently reproduce it)?
     
  2. nsxdavid

    nsxdavid

    Joined:
    Apr 6, 2009
    Posts:
    476
    Last edited: Feb 17, 2021
    DryreL likes this.
  3. DryreL

    DryreL

    Joined:
    Feb 23, 2020
    Posts:
    49
    I have same problem and no idea what is causing this error
    upload_2022-5-3_0-45-5.png