Unity-Technologies / com.unity.webrtc

WebRTC package for Unity
Other
739 stars 185 forks source link

[BUG]: Editor & App Crashes/Freezes when enable simulcast with VP8 codec in Mac Machine #890

Closed soorin1990 closed 8 months ago

soorin1990 commented 1 year ago

Package version

3.0.0-pre.4

Environment

* OS:Ventura 13.2.1 (22D68)
* Unity version: 2021.3.14f1
* Chip: Apple M1 Max
* Memory: 32 GB

Steps To Reproduce

I am trying to enable simulcast using VP8 Codec type by modifying the existing MediaStreamSample.cs with the below code

public bool isSimulcast = true;
    private RTCRtpTransceiverInit SetSimulcast(ref RTCRtpTransceiverInit init)
    {
        init.direction = RTCRtpTransceiverDirection.SendOnly;
        List<RTCRtpEncodingParameters> encodingList = new List<RTCRtpEncodingParameters>();
        RTCRtpEncodingParameters parameterH = new RTCRtpEncodingParameters();
        parameterH.maxBitrate = 4000*1000;
        parameterH.scaleResolutionDownBy = 1;
        parameterH.maxFramerate = 60;
        parameterH.active = true;
        parameterH.rid = "h";

        RTCRtpEncodingParameters parameterM = new RTCRtpEncodingParameters();
        parameterM.maxBitrate = 900*1000;
        parameterM.scaleResolutionDownBy = 1;
        parameterM.active = true;
        parameterM.maxFramerate = 60;
        parameterM.rid = "m";

        RTCRtpEncodingParameters parameterL = new RTCRtpEncodingParameters();
        parameterL.maxBitrate = 400*1000;
        parameterL.scaleResolutionDownBy = 1;
        parameterL.active = true;
        parameterL.maxFramerate = 60;
        parameterL.rid = "l";
        encodingList.Add(parameterH);
        encodingList.Add(parameterM);
        encodingList.Add(parameterL);
        init.sendEncodings = encodingList.ToArray();
        Debug.Log("simulcast set........");
        return init;
    }
    private void AddTracks()
    {
        if (isSimulcast)
        {
            RTCRtpTransceiverInit init = new RTCRtpTransceiverInit();
            SetSimulcast(ref init);
            RTCRtpTransceiver trans = _pc1.AddTransceiver(track, init);
            if (trans != null)
                pc1Senders.Add(trans.Sender);
            else
                Debug.LogError("Transceiver is null");
        }
        else
            pc1Senders.Add(_pc1.AddTrack(track));

        ***********************************
    }

When i try to run this in editor by setting the Codec Type to VP8, it works fine in Windows machine but Editor Freezes in Mac machines.

We are not sure if this is working with Intel Mac as we didnt get a chance to test it with Intel Mac Machine.

Current Behavior

Both Editor & App Crashes on running with VP8 with simulcast enabled

Expected Behavior

App should not crash and stream simulcast layers

Log:

karasusan commented 1 year ago

Thank you, we need to check this line.

Assertion at threads.c:6918, condition `this_thread_controls == thread_given_control' not met
kannan-xiao4 commented 1 year ago

memo: WRS-461

Yousif-CS commented 1 year ago

Any estimate on when we expect this issue to be fixed? This affects macOS, iOS and Android.

karasusan commented 1 year ago

@Yousif-CS Does it work on Windows or Linux platform? How about small resolution?

soorin1990 commented 1 year ago

This is working in Windows, didn't get a chance to test it on Linux.

karasusan commented 1 year ago

@soorin1990 Thank you for the valuable information. In other words, it means this issue depends on platforms.

karasusan commented 9 months ago

@soorin1990

979 is merged.