foundryvtt / foundryvtt

Public issue tracking and documentation for Foundry Virtual Tabletop - software connecting RPG gamers in a shared multiplayer environment with an intuitive interface and powerful API.
https://foundryvtt.com/
198 stars 10 forks source link

Update to PIXI 6.2.1: Resolves Token movement may reveal FOW on closed areas if areas have a active light source #4850

Closed aaclayton closed 2 years ago

aaclayton commented 3 years ago

Originally in GitLab by @neovatar

Environment Details

Issue Description

Movement of token may reveal FOW all areas that are closed off and contains an active light source. Without lights or if lights are switched of, the bug does not occur.

Scene: image Video: image

aaclayton commented 2 years ago

Nice to hear. I will slot this into our next patch version so we can update to 6.2.1 and get this closed.

aaclayton commented 2 years ago

Originally in GitLab by @dev7355608

Update: The upstream issue was fixed in pixi.js 6.2.1.

aaclayton commented 2 years ago

Originally in GitLab by @anathemamask

Just touching this to indicate that the upstream bug in Pixi is still open at this time.

aaclayton commented 3 years ago

Thank you all for the research into this. Marking this bug as blocked by the upstream issue https://github.com/pixijs/pixi.js/issues/6822

aaclayton commented 3 years ago

Originally in GitLab by @neovatar

@dev7355608 Yes, bunny test is working.

I patched my Foundry instance for now. I also subscribed https://github.com/pixijs/pixi.js/issues/6822, just tag me there if you would like me to test PIXI workarounds.

Thanks for your help <3 <3 <3

aaclayton commented 3 years ago

Originally in GitLab by @dev7355608

@neovatar A PIXI dev might ask for assistance in testing other workarounds if you want to help.

I suppose the best way to implement the workaround would be to test if rendering to texture doesn't work properly and only then render twice. Something like this. Does this work? It should show the triangular bunny face again.

aaclayton commented 3 years ago

Originally in GitLab by @neovatar

Just tried with

canvas.app.renderer.render(fog.explored, tex, undefined, transform);
canvas.app.renderer.render(fog.explored, tex, undefined, transform);

in foundry.js and that works. What is the best way to proceed?

aaclayton commented 3 years ago

Originally in GitLab by @neovatar

Ok. That's good to know. I assume it does work in Chrome on the same machine?

Yes, all three examples working with Chrome and Chromium.

And does this show the triangular bunny face?

Yes! :dancer:

aaclayton commented 3 years ago

Originally in GitLab by @dev7355608

It's very likely this issue and not even a PIXI bug but entirely Firefox's fault. The author of the issue found a workaround which is to render to the texture twice. If the last test doesn't fail then it's the same issue.

aaclayton commented 3 years ago

Originally in GitLab by @dev7355608

Ok. That's good to know. I assume it does work in Chrome on the same machine?

And does this show the triangular bunny face?

aaclayton commented 3 years ago

Originally in GitLab by @neovatar

Calling canvas.sight.commitFog() manually triggers the bug instantly, correct?

Yes, triggers it instantly.

  • Test 1: a bunny should be in the top left corner.
  • Test 2: same image as test 1.
  • Test 3: just the triangular face of the bunny.

All three show the same bunny, so Test 3 fails.

aaclayton commented 3 years ago

Originally in GitLab by @dev7355608

@neovatar I failed to mention: the token is hidden by the fog texture when you execute the script. You should be still able to select and move it if the bug is not triggered instantly. Does an error message pop up when you paste the script in the console?

Calling canvas.sight.commitFog() manually triggers the bug instantly, correct?

It looks like that masking isn't working correctly when rendering to texture. Here are some simple test with their expected results:

Let me know if one of these test fail.

aaclayton commented 3 years ago

Originally in GitLab by @neovatar

Before pasting your script:

image

After pasting script (could not move Token):

image

I triggered a fog reset and:

image

I have setup a local FoundryVTT 0.7.9 and noticed that the bug is always triggered when commitFog() is called. It seems that in foundry.js:39175 the following call:

canvas.app.renderer.render(fog.explored, tex, undefined, transform);

seems to render the FOW texture, but all ambient lights create visible parts, like the lights are handled as revealing FOW. Once the fog/texture is rendered this way and replaces the saved texture, it gets visible on the screen and is saved.

With these lines commented out:

    // Swap the staging texture to the rendered Sprite
    //fog.saved.texture.destroy(true);
    //fog.saved.texture = tex;

the bug does not happen and the displayed fog stays correct. So I assume that the bug happens in the way canvas.app.renderer.render(fog.explored, tex, undefined, transform); renders the texture. So probably the "fog object" is correct, only the texture created for optimizing is "corrupt"?

aaclayton commented 3 years ago

Originally in GitLab by @dev7355608

@neovatar Try this: image

aaclayton commented 3 years ago

Originally in GitLab by @neovatar

@dev7355608 I cannot access the js file you linked :(

image

aaclayton commented 3 years ago

Originally in GitLab by @dev7355608

@neovatar I created a script that should capture the exact point where it the fog gets messed up. But it forces commits every frame, so it might not trigger the bug when it fails only on first commit.

Reset fog of war and copy & paste the script in the console. Then try to trigger the bug and take a screenshot. It should stop the movement as soon as the fog is messed up.

image

aaclayton commented 3 years ago

Originally in GitLab by @neovatar

@aaclayton @dev7355608 Are there any debug options that I can set to generate more helpful logs/insights to help? I tried with CONFIG.debug.sightRays = true, but ray casting seemed normal when the bug happened.

I also tried CONFIG.debug.fog = true and noticed the following: The bug happens always on the first save of the fog exploration data.

SightLayer | Updating fog exploration for new explored position. 9 foundry.js:39304:37
SightLayer | Committing fog exploration to render texture. foundry.js:39158:37
SightLayer | Saving exploration progress to FogExploration document. foundry.js:39262:37
Saved Fog of War exploration progress in Scene dCaNApOgzmBWBgHf foundry.js:39342:13

All the updates of the fog are ok, but when a commit/save is triggered, it reveals the whole fog. I assume it happens somewhere in commitFog() when the texture swapping is done.

aaclayton commented 3 years ago

Originally in GitLab by @dev7355608

I tried to reproduce it on my Linux machine today (same Firefox version, but Ubuntu 20.04, and AMD graphics card), but not luck so far.

Maybe it's related to #4442.

aaclayton commented 3 years ago

Originally in GitLab by @neovatar

I was only able to reproduce it with Firefox+Linux. So it's probably a rather arcane bug. Have you tried the Linux/Firefox 87 combo? If yes and the bug did not occur: Which graphic hardware and driver did you use? It may be nvidia related...

aaclayton commented 3 years ago

Hey @neovatar - I haven't ever seen this occur nor have I been able to reproduce it by following similar steps. I'll see if I can figure out a set of repro steps for this, but this is pretty strange and not something I've seen before.