millicast / millicast-player-unreal-engine-plugin

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

In version 1.4, stopping and/or restarting a stream when it's subscribed to causes a memory leak, leading to a crash #32

Closed adrian-j-programmer closed 1 year ago

adrian-j-programmer commented 1 year ago

Hi,

Here's the repro steps for the memory leak that leads to a crash:

  1. Start publishing to a stream endpoint in OBS.
  2. Subscribe to that stream in UE
  3. Stop streaming in OBS
  4. Start streaming in OBS again
  5. Notice UE4 performance takes a hit and eventually the game crashes OOM.

Cheers, Adrian Jakubiak, Game Director, Odyssey

maximeLong commented 1 year ago

One clarification from our side on this issue - we only test our app in multiplayer client mode, never in standalone. This might have an effect on this issue.

dcoffey3296 commented 1 year ago

@adrian-j-programmer, @maximeLong, is this regular OBS via RTMP or OBS-WebRTC?

adrian-j-programmer commented 1 year ago

It's OBS-WebRTC

adrian-j-programmer commented 1 year ago

I was able to track down the source of this issue to an implementation detail in our integration of the plugin. The crux here is that a millicast media track allows the same consumer to be added multiple times. This should not be allowed, as there is no benefit to allowing this behavior. Especially now when video consumers are getting lost at random, the hack workaround for this being readding the consumer to the track can easily lead to falling into this memory leak trap.

dbaldassi commented 1 year ago

I have added a check to avoid adding the same consumer 2970779