SwiftSemanticSearch icon indicating copy to clipboard operation
SwiftSemanticSearch copied to clipboard

App crashes when I try to search after the index is loaded.

Open Hyukjae-Jang opened this issue 1 year ago • 7 comments

  • The main cause of the previous issue: #4 The main cause was that the index file, images.uform3-image-text-english-small.usearch, was missing both in the project and target membership. After manually adding the index file, the app can read the imageIndex from the bundle file.

  • However, the app crashes if I try to search after the index is fully loaded. I wonder that USearchIndex.load() might need a fix. This also happens when I load the index file saved by a previous PR: #7

Xcode: 16.1 MacOS: Sonoma 14.7.1 Device: iPhone 16 Plus - iOS 18.0 Simulator: iPhone 16 - iOS 18. 1, iPhone SE 3rd Gen - iOS 17.5

Console Log:

Wants to filter images by B
libc++abi: terminating due to uncaught exception of type std::runtime_error: No available threads to lock
Type: studio

Stack images: image image

Hyukjae-Jang avatar Nov 14 '24 01:11 Hyukjae-Jang

Is it using the newest USearch? Can you try calling "reserve" before "search"?

ashvardanian avatar Nov 14 '24 09:11 ashvardanian

Is it using the newest USearch?

Yes, it's the main branch

Can you try calling "reserve" before "search"?

After adding reserve before search, the crash is resolved. I will prepare a P.R. for this. BTW, I wonder how this resolved the crash. Would you explain about this a little bit?

Hyukjae-Jang avatar Nov 15 '24 03:11 Hyukjae-Jang

Sure, @Hyukjae-Jang! I've made a mistake in the complex logic of pre-allocating thread-specific pools after the index is loaded into memory. Reserving memory allocates the needed buffers. Thanks!

ashvardanian avatar Nov 16 '24 15:11 ashvardanian

@Hyukjae-Jang, just FYI, that should a PR to the USearch Obj-C binding. Specifically the load interface. Thanks again!

ashvardanian avatar Nov 16 '24 15:11 ashvardanian

PR is opened (https://github.com/ashvardanian/SwiftSemanticSearch/pull/9). Please take a look.

BTW, will there be a patch for this issue on the USearch Obj-C binding side?

Hyukjae-Jang avatar Nov 19 '24 00:11 Hyukjae-Jang

@ashvardanian will there be a patch on the USearch Obj-C binding side?

cnhhoang850 avatar May 05 '25 06:05 cnhhoang850

@cnhhoang850, I'm currently more focused on the algorithmic improvements than specific bindings. I've merged some of the proposed patches. Which one are you interested in?

ashvardanian avatar May 07 '25 17:05 ashvardanian