Skip to content

[Bug] CesiumCreditSystem: NullReferenceException on exit #685

Description

@Jastman

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Fields

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions