millicast / millicast-player-unreal-engine-plugin

Millicast Player plugin for Unreal Engine
Other
19 stars 15 forks source link

UE5 Fatal Error, Crashes EXCEPTION ACCESS VIOLATION or Freezes of App on Level switch #70

Closed MaxDorn96 closed 1 year ago

MaxDorn96 commented 1 year ago

Hello, we have been experiencing a few Crashes recently in different forms on Level switching.

I was able to backtrack it to the Authentication Function of the Millicast Director, if we never called this it never happens anymore. We also tried it once more in a sepreate Project and were able to replicate it.

So basically to replicate this error we do the following.

We think that Looping the Authentication and switching Levels is the cause of it all. Maybe because the Authenticate Function fires an HTTP/REST call to the Millicast API and if one switches the Level, aka destory this Actor by doing so, creates a crash because the Answer from HTTP didn't arrive yet?

By calling this Function as well as opning a Level through a Button click we were able to replicate this behaviour way more easily, because before that we would just Delay a few seconds on BeginPlay and Open a new Level and waited for this to happen to verify.

It also seemed that Packaging for Distrubution was kind of necessary as well since without it this Crash didn't occur as often, only if you were to spam this button a lot.

Since we are required to somehow Loop the Authenticate in order to check if a Stream is currently active to Subscribe to it we would really need a fix for this because it seems like this is giving a randomness factor for a crash into our Application.

We are currently working on this commit with UE5.1.1 Binary Engine (516084dc4c682f39d43e981a2abb4db1ce7bf47a)

MaxDorn96 commented 1 year ago

I just tested it again with the least Millicast calls possible to ensre it isnt a weird bug

image

image

image

This here was my Setup and it still crashed as mentioned before.

We basically have a Hardcoded MillicastSource which I set als default in the components. The last Image is our Playercontroller. We basically just call StartAuth and OpenLevel on a Keyboard Press and then it will crash in Builds, sometimes it also crashes the Editor but not as frequently.

MaxDorn96 commented 1 year ago

In our original Blueprint which is a little more advanced than this we basically start a Timer Event (Basically a Loop with Delay) to try to Authenticate since we need to check if a Stream is currently active every now and then.

So we basically try to Authenticate like every 5 seconds. If we succed we stop the loop and properly Subscribe to the Stream and OnActive will get played as intended.

Since the Mediasource doesnt really change on runtime (So we always use the same Streamname for 1 Blueprint) we never need to enter this loop again since we are already subscribed, so if one ends the stream and someone else starts a stream the OnActive event just is getting called so a new Authentication is not needed.

We basically can only run into this error if I were to join a world where nobody streams at the moment. If I then happen to switch the Level right when the loop calls Authenticate I might crash my Application, thats basically the sum of Information I have, I hope this helps somewhat.

I dont really know exatcly why it crashes since Unreal doesnt give me any explicit Error message, sorry for not beeing a big help on that front

rweber89 commented 1 year ago

Hi @MaxDorn96 I will have something within 24h for you to check whether or not it fixes the crash. I am currently going over our multi-threaded lifetime handling in the plugin.

MaxDorn96 commented 1 year ago

I wanna thank you once more for your fast response times and the way how you listen to the community.

We are working with some other Plugins as well which don't have this Level of support.

I hope I was able to give you enough Informations for you. Thanks again, you are amazing.

rweber89 commented 1 year ago

Hi @MaxDorn96 please try with the latest changes on the dev branch. You are most welcome!❤️

MaxDorn96 commented 1 year ago

As of now I can't seem to replicate this Crash/Error anymore with the same setup, Im super suprised how quick it looks like you were able to fix this

rweber89 commented 1 year ago

I am closing this now. @MaxDorn96 I wouldn`t be able to do it without your feedback.