Closed cjohn001 closed 2 years ago
Good catch I could of swore I dispatched it to the main :) will patch, as for dispatching to the main there is a util in nativescript core module that can be used for this
import { Utils } from '@nativescript/core';
Utils.dispatchToMainThread(()=>{})
@triniwiz : Thank you very much for the hint, I would have never found this function :)
It seems like the (detection)="OnDetection($event)" method from the MLKitView is called from a background thread. When I try to modify something in the ui within the callback function the UI breaks. On Android it breaks silently. On iOS I am observing the following error message:
It would be great if you could dispatch back to the main/ui thread before calling the callback function. Alternatively, please show in the demo application how I could execute code in the main tread in case I need to do it myself. What I need to do in the callback: Retrieve first barcode, pause scanner, navigate to a different page or show something in the ui of the same page. I have unfortunately not found any documentation in NS which explains threading topics like this. However, I assume what everybody would like to have is, to have the callback function executed in the main/ui thread.