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
- Enable Flashlight qs tile in Essentials
- Toggle the flashlight on/off from qs tile Essentials provide
- No flashlight, camera becomes completely unavailable
- 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.
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 setTorchOffThe 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
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:
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.