mediasoup-ios-client icon indicating copy to clipboard operation
mediasoup-ios-client copied to clipboard

"error creating transceiver" when simulcast enabled on iPhone5s

Open Rockjan opened this issue 3 years ago • 7 comments

Hi , sorry to trouble you again. The problem is when I enable simulcast like this :

        NSMutableArray *codecs = [[NSMutableArray alloc] initWithCapacity:3];
        [codecs addObject:[RTCUtils genRtpEncodingParameters:YES maxBitrateBps:500000 minBitrateBps:0 maxFramerate:60 numTemporalLayers:0 scaleResolutionDownBy:4]];
        [codecs addObject:[RTCUtils genRtpEncodingParameters:YES maxBitrateBps:1000000 minBitrateBps:0 maxFramerate:60 numTemporalLayers:0 scaleResolutionDownBy:2]];
        [codecs addObject:[RTCUtils genRtpEncodingParameters:YES maxBitrateBps:1500000 minBitrateBps:0 maxFramerate:60 numTemporalLayers:0 scaleResolutionDownBy:1]];
        producer = [weakSelf.sendTransport produce:nil track:videoTrack encodings:codecs codecOptions:nil];

my test device , a iPhone5s(iOS12.4.8) very easy to crash and report a message: "error creating transceiver", but this problem never happened on other devices (iPhone6 or above).

Rockjan avatar Aug 17 '20 01:08 Rockjan

Error also happened on my iPhone X (iOS13.6)...

Rockjan avatar Aug 20 '20 07:08 Rockjan

Finally, I fixed the bug . The problem is type conversion (oc->c++):

The wrong code:

            if (encoding.maxBitrateBps != nil) nativeEncoding.max_bitrate_bps = (int)(size_t)encoding.maxBitrateBps;
            if (encoding.minBitrateBps != nil) nativeEncoding.min_bitrate_bps = (int)(size_t)encoding.minBitrateBps;
            if (encoding.maxFramerate != nil) nativeEncoding.max_framerate = (int)(size_t)encoding.maxFramerate;
            if (encoding.numTemporalLayers != nil) nativeEncoding.num_temporal_layers = (int)(size_t)encoding.numTemporalLayers;
            if (encoding.scaleResolutionDownBy != nil) nativeEncoding.scale_resolution_down_by = (double)[encoding.scaleResolutionDownBy doubleValue];

and the correct code should be :

            if (encoding.maxBitrateBps != nil) nativeEncoding.max_bitrate_bps = absl::make_optional(encoding.maxBitrateBps.intValue);
            if (encoding.minBitrateBps != nil) nativeEncoding.min_bitrate_bps = absl::make_optional(encoding.minBitrateBps.intValue);
            if (encoding.maxFramerate != nil) nativeEncoding.max_framerate = absl::make_optional(encoding.maxFramerate.doubleValue);
            if (encoding.numTemporalLayers != nil) nativeEncoding.num_temporal_layers = absl::make_optional(encoding.numTemporalLayers.intValue);
            if (encoding.scaleResolutionDownBy != nil) nativeEncoding.scale_resolution_down_by = absl::make_optional(encoding.scaleResolutionDownBy.doubleValue);

Rockjan avatar Aug 20 '20 12:08 Rockjan

Hello, sorry for the late reply, been busy... If possible could you create a pull request with your fix?

ethand91 avatar Sep 02 '20 09:09 ethand91

Hi any suggestion regarding group video chat

sivakumaraketi avatar Sep 12 '20 10:09 sivakumaraketi

@ethand91 hey there. Great job on the pod. I was wondering if you by chance could update the pod with the fix @Rockjan suggested. Cause currently latest pod produces same crash when using:

    var encodings: Array = Array<RTCRtpEncodingParameters>.init()
    encodings.append(RTCUtils.genRtpEncodingParameters(true, maxBitrateBps: 500000, minBitrateBps: 0, maxFramerate: 60, numTemporalLayers: 0, scaleResolutionDownBy: 0))
    encodings.append(RTCUtils.genRtpEncodingParameters(true, maxBitrateBps: 1000000, minBitrateBps: 0, maxFramerate: 60, numTemporalLayers: 0, scaleResolutionDownBy: 0))
    encodings.append(RTCUtils.genRtpEncodingParameters(true, maxBitrateBps: 1500000, minBitrateBps: 0, maxFramerate: 60, numTemporalLayers: 0, scaleResolutionDownBy: 0))
    producer = mediasoupSendTransport.produce(self,
                                   track: videoTrack,
                                   encodings: encodings,
                                   codecOptions: codecOptions,
                                   appData: appData)

Thanks

Rostyk avatar Jan 21 '21 16:01 Rostyk

Hi,

I'm encountering this crash in all my iOS devices, so is there any way to bring this fix into the pod, or some other workaround?

mominawahab avatar Jun 03 '21 11:06 mominawahab

@ethand91 Could you please release the library and update the pod with the latest code so everyone can use it with the bag fixed. Thank you

bondareb-evgenii avatar Jun 03 '21 16:06 bondareb-evgenii