ethand91 / mediasoup-ios-client

Mediasoup 3 iOS Client
ISC License
131 stars 65 forks source link

"error creating transceiver" when simulcast enabled on iPhone5s #75

Open Rockjan opened 4 years ago

Rockjan commented 4 years ago

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 commented 4 years ago

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

Rockjan commented 4 years ago

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);
ethand91 commented 4 years ago

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

sivakumaraketi commented 4 years ago

Hi any suggestion regarding group video chat

Rostyk commented 3 years ago

@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

mominawahab commented 3 years ago

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?

bondareb-evgenii commented 3 years ago

@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