opentok-ios-sdk-samples-swift icon indicating copy to clipboard operation
opentok-ios-sdk-samples-swift copied to clipboard

Memory Issue + Crash with OpenTok / WebRTC with iPhone 11 Pro Max running iOS 13.3.1

Open jrz-afs opened this issue 4 years ago • 1 comments

Hi OpenTok,

I am encountering a strange issue with memory allocation on a basic video chat such that as soon as calls are made to OTVideoCaptureConsumer's consumeFrame(_:) method, memory spikes from about 100MB to 2.5GB. Such a rapid spike in memory causes iOS to terminate the app.

I have three physical devices I am testing with: an iPhone 11 Pro (256GB), an iPhone 11 Pro Max (512GB), and an iPad Pro (64GB). However, this issue only happens on the iPhone 11 Pro Max (512GB). It happens every time. All devices are running the same non-beta iOS version, iOS 13.3.1.

I profiled the memory usage in Xcode's instruments, and it is drastically different on the 11 Pro Max. The other two devices (the 11 Pro and iPad Pro) demonstrate similar growth curves, such that once the video streaming begins, their memories balloon to 850MB, and then plateau. Occasionally, they'll exceed 1GB, but then come back down, averaging out to approx. 850MB. However, on the 11 Pro Max, it balloons to 850MB, then 1.1GB, and then 2GB, and the 2.5GB, at which point iOS terminates the app. Again, this happens every time.

The application's (Swift) code is exactly the same between test runs (obviously, or this wouldn't be a question), and it looks like the 11 Pro Max is making an excessive/abnormal number of calls to WebRTC's vpx_memalign method. This all happens within the span of about 0.5 seconds.

I have been extremely careful with memory allocation in the application, keeping memory to around 80-150MB on average. However, as soon as a video call starts and frames are consumed, the memory spikes to these crazy levels, but only on the iPhone 11 Pro Max. In this case, I'm just not sure what else I can do since all the method calls that result in this ballooned memory profile occur at a lower level, in the OpenTok / WebRTC libraries.

For what it's worth, I am running OpenTok version 2.16.5; however, I did try rolling back to older versions with no success.

  • Has anyone experienced this before or heard of similar issues?
  • Is this the correct location for this discussion, or should I be posting elsewhere?
  • What other information can I provide so that someone can investigate this further?

Thank you.

jrz-afs avatar Mar 16 '20 03:03 jrz-afs

@jrz-afs Can you try using objective-c Basic-Chat sample code and see if that is also giving same crash ? also try setting the publisher's cameraResolution to OTCameraCaptureResolutionLow or OTCameraCaptureResolutionMedium My guess is, for some reason the OpenTok's internal capturer is using very high camera resolution on iPhone 11 Pro Max.

On the other hand, you can use Custom-Video-Driver sample code and validate the camera video frame pixel buffer in catureOutput: callback before we call consumeFrame .

bsrao avatar Mar 16 '20 16:03 bsrao