VLprojects / mediasoup-client-swift

Swift wrapper for libmediasoupclient
MIT License
39 stars 16 forks source link

Laggy video in iPhone #17

Open samchen7910 opened 11 months ago

samchen7910 commented 11 months ago

Firstly, thanks for the package, it's awesome. I'm facing an issue the video stream from iPhone is extremely laggy but iPad is working fine. with the same code.

iPhone 12 with iOS versions 15.5 and 16.6 iPad 2020 with iPadOS version 16.5.1

Pictures below show that when iPhone joins a room, the RAM goes up to 600mbs+, while iPad stays at 170mbs+

Screenshot 2023-08-08 at 14 38 12 Screenshot 2023-08-02 at 15 17 55
fedulvtubudul commented 11 months ago

First guess is to check your video quality. iPhone camera native resolution and frame rate are really too much for realtime streaming, so you should set it thoughtfully. What resolution and frame rate do you capture from camera and what resolution (or resolutions) do you encode and stream?

Here are two runs of same code on same device I've just done, but with different video quality settings:

Screenshot 2023-08-08 at 22 04 38 Screenshot 2023-08-08 at 21 59 05
samchen7910 commented 11 months ago

Thanks for quick response @fedulvtubudul Here are the resolution and frame rate which I captured from iPhone's camera. In the encoding part, I leave it at Nil. This setup works well with the mediasoup_ios_client. Could you tell me which resolution, frame rate, and encoded resolution did you use?

Screenshot 2023-08-08 at 15 40 29 Screenshot 2023-08-08 at 15 39 37
fedulvtubudul commented 11 months ago

640x360@20fps is not that much to be a problem. Have you tried to examine your app with Instruments and see where all the memory goes?