googlesamples / mlkit

A collection of sample apps to demonstrate how to use Google's ML Kit APIs on Android and iOS
Apache License 2.0
3.55k stars 2.93k forks source link

[Bug report] iOS app crashes: Expected MLKObject but found MLKDefaultObject #415

Closed HafizAhsan1 closed 2 years ago

HafizAhsan1 commented 2 years ago

Describe the bug As soon as capture session starts, app gets crashed while running on debug/development mode and console produces the following exception Swift/ArrayBuffer.swift:510: Precondition failed: NSArray element failed to match the Swift Array Element type Expected MLKObject but found MLKDefaultObject To Reproduce Although the crash is very random and does not have any specific steps to be reproduced but following steps can be taken to reproduce the behavior in sample app:

  1. As soon as camera opens ( captures session starts ), block the camera with hand and shake the phone until you get a crash.
  2. Give the application a run 6-8 times while on debug mode (development profile) and app will crash randomly as soon as capture starts.
  3. On crash, Xcode will show the reason as "Swift/ArrayBuffer.swift:510: Precondition failed: NSArray element failed to match the Swift Array Element type Expected MLKObject but found MLKDefaultObject"

If applicable, please include code snippet and sample input(image, video, text, etc)

Expected behavior The application should not crash even on debug mode.

SDK Info:

Smartphone:

Development Environment:

bcdj commented 2 years ago

The error indicates Swift/ArrayBuffer.swift:510. I'm curious what you have on and around line 510 of Swift/ArrayBuffer.swift... Can you reproduce the issue using ML Kit's quickstart sample app? It contains a swift app doing Object Detection and Tracking which returns an array of Object.

bcdj commented 2 years ago

Looks like you are cross posting the same question on StackOverflow as well. Let's close this github bug report here and use the StackOverflow post for further discussion.