Skip MeasuredTemplate placeables whose _draw left them incomplete#313
Open
takaqiao wants to merge 1 commit into
Open
Skip MeasuredTemplate placeables whose _draw left them incomplete#313takaqiao wants to merge 1 commit into
takaqiao wants to merge 1 commit into
Conversation
A MeasuredTemplate placeable can survive into canvasReady without
this.template (the PIXI.Graphics) or a registered highlight layer:
loadTexture rejects on a missing/failing fill, the system migrated
spell areas off MeasuredTemplate (PF2e v8 places Regions instead, but
legacy scene documents remain), or the placeable was created before
the canvas finished initializing.
The bundle currently dereferences both unconditionally:
- _singleLoadFilters does
placeable.document.tmfxTextureAlpha = placeable._TMFXgetSprite().alpha = updateData.opacity;
which throws TypeError 'Cannot set properties of undefined' when
_TMFXgetSprite() returns undefined for a TEMPLATE whose this.template
was never assigned.
- The defaultTemplateOnHover mousemove handler does
hl.renderable = ...; template.template.alpha = ...;
and crashes hundreds of times per second on a hover when either is
missing.
Both reproduce on Foundry v14 + PF2e v8 worlds with leftover legacy
MeasuredTemplate documents.
Skip the broken placeables instead of dereferencing through undefined.
The Region branch already guarded its sprite this way; this brings
TEMPLATE and the hover handler in line.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A
MeasuredTemplateplaceable can survive intocanvasReadywithoutthis.template(itsPIXI.Graphics) or a registered highlight layer:loadTexturerejects on a missing/failing fill texture and_drawaborts beforethis.template = this.addChild(new PIXI.Graphics()).MeasuredTemplate— PF2e v8 placesRegiondocuments instead, but legacyMeasuredTemplatedocuments from older PF2e versions are still present in scene data.The bundle currently dereferences both unconditionally and throws on those.
Repro
Foundry v14 + PF2e v8 world with any legacy
MeasuredTemplatedocuments in a scene. On scene activation:And then on every pointer move once
defaultTemplateOnHoveris on:Changes
_singleLoadFilters(module/tokenmagic.js): for theTEMPLATEbranch, fetch_TMFXgetSprite()once and skip the alpha/tint assignments when it returns null/undefined. TheREGIONbranch already guarded its sprite this way; this brings the template branch in line.defaultTemplateOnHovermousemove handler (module/settings.js):continuepast templates whosetemplate.templateis missing, and past templates whose grid highlight layer didn't get registered (the previous expressionhl.renderable = …crashed otherwise).No behavioural change for templates that drew successfully — broken templates are simply skipped instead of taking down the canvasReady chain or the pointermove pipeline.
Test plan
MeasuredTemplatedocuments: canvasReady completes without throwing, pointer moves don't spam errors, and any healthy templates in the same scene still behave normally._drawfinishes.