Forum Post: https://community.cesium.com/t/crash-on-application-exit-in-cesiumcreditsystem/45952
Category: Cesium for Unity
Reported by: @MYavuzSelim
Description
Two bugs in CesiumCreditSystem.cs reported via the forum:
Bug 1 — NullReferenceException in OnDestroy()
_images is initialized in OnEnable(), but OnDestroy() accesses this._images.Count unconditionally (line ~174). If the prefab is loaded but never enabled, OnEnable() never runs, _images stays null, and OnDestroy() crashes on exit.
There is also a misplaced null check inside the loop body:
if (this._images != null) // inside the loop — can't help here
This guard needs to wrap the entire loop, not sit inside it.
Fix: Null-guard this._images before the loop in OnDestroy().
Bug 2 — Double OnEnable() call / delegate subscribed twice
See #683
Steps to Reproduce
(To be confirmed by reporter — suspected trigger: prefab loaded without being enabled, or default credit system instantiated via GetDefaultCreditSystem())
Opened by Cesium DevRel from forum triage.
Forum Post: https://community.cesium.com/t/crash-on-application-exit-in-cesiumcreditsystem/45952
Category: Cesium for Unity
Reported by: @MYavuzSelim
Description
Two bugs in
CesiumCreditSystem.csreported via the forum:Bug 1 — NullReferenceException in
OnDestroy()_imagesis initialized inOnEnable(), butOnDestroy()accessesthis._images.Countunconditionally (line ~174). If the prefab is loaded but never enabled,OnEnable()never runs,_imagesstaysnull, andOnDestroy()crashes on exit.There is also a misplaced null check inside the loop body:
This guard needs to wrap the entire loop, not sit inside it.
Fix: Null-guard
this._imagesbefore the loop inOnDestroy().Bug 2 — Double
OnEnable()call / delegate subscribed twiceSee #683
Steps to Reproduce
(To be confirmed by reporter — suspected trigger: prefab loaded without being enabled, or default credit system instantiated via
GetDefaultCreditSystem())Opened by Cesium DevRel from forum triage.