Skip to content

[Bug]: Flashlight brightness control crashes camerahalserver on Mediatek devices (SIGABRT) #465

@adam-adrian

Description

@adam-adrian

Bug Description

Using the Flashlight QS tile from Essentials causes a fatal crash (SIGABRT) in camerahalserver on Mediatek devices. The crash originates from a state machine violation in the Mediatek Camera HAL:

Abort message: [onGetTorchStrengthLevelLocked] Cannot setTorchLevel after setTorchOff

The HAL asserts that setTorchLevel must not be called after setTorchOff. Essentials appears to call setTorchLevel (for brightness/fade effect) without ensuring the torch is in an active state first. This causes the camera provider to crash and restart in a loop (observed 14 consecutive crashes), making ALL cameras (IDs 0–6) unavailable until the HAL eventually self-recovers.

Steps to Reproduce

  1. Enable Flashlight qs tile in Essentials
  2. Toggle the flashlight on/off from qs tile Essentials provide
  3. No flashlight, camera becomes completely unavailable
  4. Check logcat for camerahalserver SIGABRT

Expected Behavior

Flashlight brightness control should work without crashing camerahalserver.
The app should ensure torch is in an active/on state before calling setTorchLevel.

Screenshots

No response

Android Version

Android 16 (HyperOS 3.1)

Device

Xiaomi POCO X7 Pro (nezha, Dimensity 9300+)

App Version

15.2

Additional Context

Logcat abort message:

[onGetTorchStrengthLevelLocked] Cannot setTorchLevel after setTorchOff - 0:0 (onGetTorchStrengthLevelLocked){#618:vendor/mediatek/proprietary/hardware/mtkcam+android/main/hal/devicemgr/depend/CameraDeviceManagerImpl.cpp}

Possible fix: guard setTorchLevel calls with a check that the torch is currently enabled/on before adjusting brightness level.

Note: This issue is specific to Mediatek HAL. Pixel (Qualcomm/Google HAL) likely does not enforce this state assertion strictly.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions