Skip to content

[Crashlytics] com.google.mlkit:face-detection@@16.1.7 - com.google.mlkit.vision.face.bundled.internal.ThickFaceDetectorCreator.<clinit> #195

Closed

Description

@stozo04

Automated triage — a new fatal crash was reported by Firebase Crashlytics.


@claude please triage this crash. Use the Firebase MCP Crashlytics tools to fetch the
stacktrace and sample events for issue 37081b243b0f5bf705e7e5e8ccd47489, consult docs/lessons_learned/,
and post a root-cause comment. If you can point to a specific cause in the code, open a
draft PR with a minimal fix per docs/DEFINITION_OF_DONE.md (note CI could not run
the emulator). Otherwise label needs-human and explain. Never auto-merge.

Activity

  1. claude commented on Sep 13, 2026

    @claude

    Root-cause analysis

    MCP note: crashlytics_list_events returned an empty array (no sample events retrieved under this workflow's service-account auth — see issue #107). Triage is based on the issue metadata, the stacktrace in the title/subtitle, docs/lessons_learned/, and the source code.


    Failing frame

    com.google.mlkit.vision.face.bundled.internal.ThickFaceDetectorCreator.<clinit>
    java.lang.UnsatisfiedLinkError: dlopen failed: library "libface_detector_v2_jni.so" not found
    

    Root cause

    FaceTracker initializes the ML Kit face detector at field-init time with no error handling.

    // camera/lens/FaceTracker.kt:50
    private val detector = FaceDetection.getClient(
        FaceDetectorOptions.Builder()…
    )

    When this field is initialized, ML Kit's ThickFaceDetectorCreator.<clinit> (the bundled model's static initializer) calls System.loadLibrary("face_detector_v2_jni"). On affected devices, dlopen cannot find libface_detector_v2_jni.so — most likely because that device's ABI is not covered by the bundled ML Kit 16.1.7 AAR, or the library fails 16 KB page-alignment mapping on an Android 15 device with 16 KB page size. The resulting UnsatisfiedLinkError propagates uncaught as ExceptionInInitializerError → fatal crash.

    Files involved

    • app/src/main/java/io/github/stozo04/openloop/camera/lens/FaceTracker.kt — missing LinkageError guard
    • app/src/main/java/io/github/stozo04/openloop/diagnostics/ReverseCrashlytics.kt — needs reportFaceTrackerUnavailable()

    Lesson 040 precedent

    HandTracker had the identical failure mode (MediaPipe's libmediapipe_tasks_jni.so absent / static initializer crash under R8), documented in docs/lessons_learned/040-run-the-release-apk-when-a-native-dependency-lands.md. The fix there: wrap tracker creation in try/catch (error: LinkageError), set a broken flag, report a non-fatal to Crashlytics, and degrade gracefully (camera still works, face lenses show pass-through).

    FaceTracker was introduced alongside HandTracker but was never given the same resilience.

    Fix

    1. Move FaceDetection.getClient() from a field initializer into an init {} block with try/catch (error: LinkageError).
    2. On failure: set broken = true, log, report non-fatal via ReverseCrashlytics.reportFaceTrackerUnavailable().
    3. analyze() bails early when broken — camera and other lenses continue working.
    4. Add reportFaceTrackerUnavailable() to ReverseCrashlytics.

    Confidence: HIGH — the same crash shape, the same library load path, the same missing guard, and an existing pattern in the codebase to follow. A draft PR with the minimal fix follows.

  2. added a commit that references this issue on Sep 17, 2026
    4c2b20a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions