Frstrm / TokenLightCondition

Determine the lighting conditions of a token based on placed lights and token lights
MIT License
1 stars 4 forks source link

If a Token Attacher prefab with a light source attached to it is dropped onto the canvas, it causes the browser to hang. #53

Open PlasticMohawk opened 1 year ago

PlasticMohawk commented 1 year ago

Foundry v11.305 Pathfinder 2E v5.1.2 Modules: Token Light Condition v0.6.3 Token Attacher v4.5.13

Steps to reproduce: 1.) Set up a Token Attacher prefab which has a light source attached to it. the TA prefab's primary token should be within the radius of the light source. (Common use case is a "Campfire" or "Torch" prefab) 2.) With Token Light Condition enabled, drop the prefab from the right sidebar's Actors menu onto the canvas. 3.) The browser will freeze/hang. You must then close and reopen the tab, possibly needing to relog into the game world, possibly in "safe" mode (with all modules disabled).

3a.) As a control experiment, you can follow the above steps with Token Light Condition as a module enabled, but with the toggle disabled (which you find in the Lighting menu on the left - the eye icon.) Your prefab with the attached lightsource should load successfully at that point. You can then toggle the toggle back on from the Lighting menu, and everything should still work, which is further indication that the issue seems to be caused during the dropping of the prefab from the Actors menu. My hunch is that there's an issue stemming from Token Light Condition calculating the lighting state while Token Attacher is still calculating the prefab render.

3b.) Note further that Token Attacher prefabs with NO light source work fine while Token Light Condition is enabled.

This issue can be problematic if the scene you were working with is the active (vs. viewed) scene. If the browser hangs, then the next time the game world is reloaded/logged into, the scene with the problem token/lightsource is the one that's loaded. This scene will tend to get "stuck" on 99%-100% and the browser hangs again. The only way to fix this at this point is to restart the game world in "Safe" mode, which is when all of your modules are disabled. If you don't have a backup of your module settings, you must then manually re-enable all of your modules.

Frstrm commented 1 year ago

Thank you for all of the info and repro steps, much appreciated. I'm not sure I can offer a workaround until I have had a chance to dig in and take a look.

PlasticMohawk commented 1 year ago

Thank you for all of the info and repro steps, much appreciated. I'm not sure I can offer a workaround until I have had a chance to dig in and take a look.

Glad to help. It seems Token Attacher sends a notification to the screen when a dropped prefab is ready to be moved. It does this because if you try to move a TA prefab before it's fully loaded onto the canvas, the prefab will break. I haven't looked at the code, but I'm guessing there's some hook which governs this, since a "bigger" prefab will usually take longer to load than a "smaller" one. Perhaps you can hook into that to commence the light condition calculation.