keijiro / KlakSpout

Spout plugin for Unity
The Unlicense
651 stars 97 forks source link

White Flash when updated to Unity 2021.2.8f1 (URP 12.1.3) #79

Closed noisecrime closed 1 year ago

noisecrime commented 2 years ago

So this is a weird one.

I was testing this project ( KlakSpout 2.0.3) after installing Spout 2007 and confirming it work via their Demo send/receive exe.

Everything appear to work with the Test scene of the project, and viewing the output in SpoutReceiver.exe, until I notice an occasional full screen/camera white flash in both Unity and SpoutReceiver. The frequency of the flashing appeared to get worse when interacting with Unity.

My initial thought was there must be some compatibility issue between versions of the software and maybe the texture surface was getting overwritten, released or something, but to my surprise I was able to narrow it down to the unity camera background switching to RGBA( 1,1,1,1 ) for a single frame and then back again!

Unfortunately I'm at a loss to explain why or how this happens and while its fixable by forcing the camera.background to the desired color in SpoutSender.Update() prior to calling _sender.Update() its really frustrating to not know the cause.

The project is a straight copy of this github ( Assets, Packages, Plugin and ProjectSettings folders ) imported and updated to Unity 2021.2.8f1. Unity automatically installed URP 12.1.3 and later I installed visualStudio ide 2.0.14. Apart from that there were no other changes made to the project or the source until after I noticed the problem.

I find it so weird that the camera background color can change in Unity on its own. I could understand perhaps its renderTexture or the backbuffer being set to RGBA(1,1,1,1) by the plugin or 3d API if an error occurred, or if there was a bug in the plugin, but now how it could affect the background color property in Unity. The only thing I can think of is some conflict in URP and the Spout code.

Reporting this as a FYI and hoping someone may have an explanation.

I've recently downloaded 21.2.10 so will test in that as eventually I'll need to use this with HDRP and I believe there are some issues which means I need to use the 21.2.10 release.

Edit: White flash is in Unity and can be seen the Spout 2007 demo receiver and OBS using a Spout plugin.

noisecrime commented 2 years ago

opps - i'm an idiot. Just returned to Spout to make a test project using it and literally one of the first scripts I check out by accident is Timecode.cs - yep it contains a Camera.backgroundColor line to make the screen flash white!

Don't understand how I missed it before, I'm sure I did a search for 'backgroundColor' when I first came across the issue as it seemed like a reasonable assumption. I can only assume at the time my search was limited to the csproj in visual studio and that was the KlakSpout package, so it missed the line in the asset scripts.

Sorry for the bogus report - you can close this.