watson-developer-cloud / swift-sdk

:iphone: The Watson Swift SDK enables developers to quickly add Watson Cognitive Computing services to their Swift applications.
https://watson-developer-cloud.github.io/swift-sdk/
Apache License 2.0
878 stars 222 forks source link

[visual-recognition] memory issue with Core ML model under heavy usage #943

Closed devinaconley closed 5 years ago

devinaconley commented 5 years ago

Description

This problem has only been observed when the device is under very heavy stress, in this case, including high frame rate of classification against WVR Core ML models, along with ARKit usage.

The crash observed is thrown at this line in the SDK when referencing the model variable: https://github.com/watson-developer-cloud/swift-sdk/blob/06181082d79d39de6ba6222f8bda8541a920cf95/Source/VisualRecognitionV3/VisualRecognition%2BCoreML.swift#L199

The associated error message is:

thread #34: tid = 0x8174c8, 0x000000010482cd8c libclang_rt.asan_ios_dynamic.dylib`__asan::AsanDie(), queue = 'com.apple.root.user-initiated-qos', stop reason = Deallocation of non-allocated memory

{
  "access_size" : 0,
  "access_type" : 0,
  "address" : 0,
  "description" : "bad-free",
  "instrumentation_class" : "AddressSanitizer",
  "pc" : 0,
  "stop_type" : "fatal_error"
}

Reproducing

This crash can be recreated by running the ar-resume-with-visual-recognition project on the following branch: https://github.com/IBM/ar-resume-with-visual-recognition/tree/memory-leak

Versions:

Solution/workaround:

Current workaround is to throttle frame rate of classification to reduce stress on SDK. Ideally we could provide a solution to boost resiliency, even when under heavy stress.

cc: @dokun1 @sanjeevghimire

AnthonyOliveri commented 5 years ago

The memory-leak branch doesn't exist. Is there a fork that has the reproducible code?

sanjeevghimire commented 5 years ago

@AnthonyOliveri the branch should be there now

mkistler commented 5 years ago

Can this problem be reproduced in the simulator, or does it only occur on a device?

If only on a device, can you give information about the device on which the problem was recreated?

sanjeevghimire commented 5 years ago

The app requires camera so it does need device.

We got the error on iphone x, 7 plus, 6s

On Sun, Mar 3, 2019 at 12:52 PM Mike Kistler notifications@github.com wrote:

Can this problem be reproduced in the simulator, or does it only occur on a device?

If only on a device, can you give information about the device on which the problem was recreated?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/watson-developer-cloud/swift-sdk/issues/943#issuecomment-469052062, or mute the thread https://github.com/notifications/unsubscribe-auth/ABnY26AY1Y0CUgCxvAlca68A1yXXn1IFks5vTBnigaJpZM4abU41 .

-- सन्जीब िघमिरे (Sanjeev Ghimire)

jeff-arn commented 5 years ago

@mkistler let's discuss as this may still be an open issue.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs. Thank you for your contributions.