Skip to content

Fix NullReferenceException loop in AdventurerPlateStep#10

Merged
redstrate merged 1 commit into
redstrate:mainfrom
jblemee:fix/adventurer-plate-null-safety
May 1, 2026
Merged

Fix NullReferenceException loop in AdventurerPlateStep#10
redstrate merged 1 commit into
redstrate:mainfrom
jblemee:fix/adventurer-plate-null-safety

Conversation

@jblemee

@jblemee jblemee commented May 1, 2026

Copy link
Copy Markdown
Contributor

Problem

AdventurerPlateStep.NeedsUpdateEveryFrame() returns true so Run() is invoked every frame while the Adventurer Plate window is open. On the very first frames after the window opens (and apparently on some 7.5 sessions in general), AgentCharaCard.Instance()->Data->PortraitTexture or its D3D11Texture2D pointer can still be null, but GetCurrentCharaViewImage dereferences both unconditionally.

The result is a tight loop of System.NullReferenceException thrown from GetCurrentCharaViewImage, swallowed by Dalamud's per-event PluginErrorHandler, and printed as [ERR] once per frame in dalamud.log — the step also never reaches Completed?.Invoke() until the texture happens to be ready.

[ERR] [Auracite] Exception in event handler IFramework::Update
System.NullReferenceException: Object reference not set to an instance of an object.
   at Auracite.AdventurerPlateStep.GetCurrentCharaViewImage() in …/AdventurerPlateStep.cs:line 106
   at Auracite.AdventurerPlateStep.Run() in …/AdventurerPlateStep.cs:line 36

Change

  • Walk the AgentCharaCard.Instance()->Data->PortraitTexture->D3D11Texture2D pointer chain step by step inside GetCurrentCharaViewImage, returning Image? and bailing out at the first null link.
  • In Run(), also check storage for null and bail out when GetCurrentCharaViewImage returns null. The next frame retries.

When the texture is ready the existing happy-path runs unchanged and Completed fires exactly once. The error-spam in dalamud.log goes away on slow open.

Testing

Built and tested live on a 7.5 client (FR, API 15). Opening the Adventurer Plate now produces no [ERR] lines for Auracite and the step advances cleanly to the next stage. Verified the export still produces valid base-plate.png, backing.png, etc. in the resulting archive.

`Run()` is called every frame while the Adventurer Plate window is
open (NeedsUpdateEveryFrame returns true), but the very first frames
after the window opens (and apparently on some 7.5 sessions in
general) have either AgentCharaCard.Instance()->Data or its
PortraitTexture pointer still null. The current code dereferences
these unconditionally inside GetCurrentCharaViewImage and throws a
NullReferenceException, swallowed by Dalamud's per-event error
handler — the result is a flood of [ERR] log entries each frame and
the step potentially completing on a frame where the plate is only
partially populated.

  [ERR] [Auracite] Exception in event handler IFramework::Update
  System.NullReferenceException: Object reference not set to an instance of an object.
     at Auracite.AdventurerPlateStep.GetCurrentCharaViewImage() in …/AdventurerPlateStep.cs:line 106
     at Auracite.AdventurerPlateStep.Run() in …/AdventurerPlateStep.cs:line 36

Walk the AgentCharaCard.Instance()->Data->PortraitTexture->D3D11Texture2D
pointer chain step by step inside GetCurrentCharaViewImage, returning
Image? and bailing out at the first null link. In Run(), also check
storage and bail out when GetCurrentCharaViewImage returns null. The
next frame retries cleanly. Once the texture is ready the existing
happy-path runs unchanged and Completed fires exactly once.
@jblemee jblemee force-pushed the fix/adventurer-plate-null-safety branch from 969c826 to 6222ae4 Compare May 1, 2026 00:20
@redstrate redstrate merged commit 214296f into redstrate:main May 1, 2026
1 check failed
@jblemee jblemee deleted the fix/adventurer-plate-null-safety branch May 1, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants