llealloo / audiolink

Audio reactive prefabs for VRChat
Other
346 stars 38 forks source link

Fixed an error with null reference on VRC exit. #295

Closed ShingenPizza closed 5 months ago

ShingenPizza commented 5 months ago

I noticed that whenever* i exit VRC while on my map with AudioLink, while i have that map's project open**, i get an error in the console: image

Apparently during cleaning stuff up the DisableAudioLink() method gets called after audioRenderTexture becomes null, so an attermpt to set its updateMode throws an exception.

This PR fixes it by checking if audioRenderTexture is null.

* sometimes it stops doing that, but works again after project reopen ** no matter if VRC has been run through the "build and test" or normally through Steam

float3 commented 5 months ago

@pema99 can merge?

pema99 commented 5 months ago

what.. I'd like to understand why this happens

I noticed that whenever* i exit VRC while on my map with AudioLink, while i have that map's project open**, i get an error in the console:

doesn't udon have some kind debugging mode when you do this?

pema99 commented 5 months ago

it looks ok to merge, but I guess if we do this we should match it with a null check in EnableAudioLink

ShingenPizza commented 5 months ago

what.. I'd like to understand why this happens

assets packaged with that scene somehow get unloaded faster than the scene itself, so the references become invalidated? idk

it looks ok to merge, but I guess if we do this we should match it with a null check in EnableAudioLink

it surely wouldn't hurt, but it is probably impossible for it to be null during the enable action (unless someone starts playing around with it too much), and if it somehow ended up as null during the enable, then the whole AL probably should stop working altogether with some major error message, because it would break soon after anyway...

pema99 commented 5 months ago

fair point. this seriously should never happen, so I'm just going to assume its a bug with the udon debugging setup

ShingenPizza commented 5 months ago

doesn't udon have some kind debugging mode when you do this?

fair point. this seriously should never happen, so I'm just going to assume its a bug with the udon debugging setup

to be clear, as i wrote before, it also happens when you start it up from Steam. i do have all the debug launch options turned on, but i'm pretty sure it doesn't affect VRC's behaviour, just increases the logging. i don't know how does the error-appearing-in-my-Unity-editor-console work, but it's not the first time it did. normally you just can't see errors such as this, and it doesn't really matter that it does happen when you're shutting down the whole process, however it can still be seen in logs. at least with my increased logging launch options. i've also just had the same bug happen on my friend's map, and somehow it appeared in my homeworld's project's console too.

i'd call it a bug with the order of things that get cleaned up while shutting down VRC, possibly due to some race conditions.

anyway, thanks for merging.