Search code examples
androidfirebasefirebase-mlkitgoogle-mlkit

Is firebase OnSuccessListener run on a separate thread?


I'm using google's firebase for object detection. You run it something like this:

Task<List<FirebaseVisionFace>> result =
    mDetector.detectInImage(FirebaseVisionImage.fromBitmap(dcBitmap))
                                        .addOnSuccessListener(  //etc, etc

Now I'm trying to understand how much this call impacts my apps frame rate, since it happens in the camera loop. I tried putting TimmingLogger splits around it but it told me that call returns in about 1ms. But clearly if I comment out the detector my fps goes way up. So I'm curious if anyone knows if this code is actually being called on a separate thread? Or have I somehow interrupted the operation of my thread and let it run this detection? I guess I'm trying to understand where the work is done and how to measure how much time it takes.


Solution

  • The detector itself runs in a separate thread, but the success listener is then invoked on the main/UI thread again.