Skip to content

Fix app crash when switching from "BACK 86" camera with zoom slider open and value below 1.0 (on Samsung S25+)#273

Merged
dimadesu merged 1 commit intomainfrom
camera-zoom-below-1.0
Feb 7, 2026
Merged

Fix app crash when switching from "BACK 86" camera with zoom slider open and value below 1.0 (on Samsung S25+)#273
dimadesu merged 1 commit intomainfrom
camera-zoom-below-1.0

Conversation

@dimadesu
Copy link
Owner

@dimadesu dimadesu commented Feb 7, 2026

Fixes #271

Fix slider crash on cameras with ultra-wide zoom (< 1.0x)

Add binding adapter that sets slider range before value to prevent
IllegalStateException when camera reports zoom ratio below the
slider's default minimum.

The adapter intercepts all three slider attributes (value, valueFrom,
valueTo) and sets them in the correct order, avoiding the race
condition where data binding could set value before the range was
updated.

Fixes crash: "Slider value(0.6) must be greater or equal to valueFrom(1.0)"


The Issue (High Level)

The Slider widget crashes when its value is outside the [valueFrom, valueTo] range at draw time.

The race condition:

  • Camera with ultra-wide lens is selected (zoom range: 0.6x - 8.0x)
  • The camera reports current zoom = 0.6x
  • Data binding updates fire, but in the wrong order:
    • zoomRatio → 0.6 (but slider still has default range 1.0-8.0)
    • zoomRatioRange → [0.6, 8.0] (too late!)
  • Slider tries to draw with value=0.6, min=1.0 → CRASH

Add binding adapter that sets slider range before value to prevent
IllegalStateException when camera reports zoom ratio below the
slider's default minimum.

The adapter intercepts all three slider attributes (value, valueFrom,
valueTo) and sets them in the correct order, avoiding the race
condition where data binding could set value before the range was
updated.

Fixes crash: "Slider value(0.6) must be greater or equal to valueFrom(1.0)"

---

The Issue (High Level)

The Slider widget crashes when its value is outside the [valueFrom, valueTo] range at draw time.

The race condition:

- Camera with ultra-wide lens is selected (zoom range: 0.6x - 8.0x)
- The camera reports current zoom = 0.6x
- Data binding updates fire, but in the wrong order:
  - zoomRatio → 0.6 (but slider still has default range 1.0-8.0)
  - zoomRatioRange → [0.6, 8.0] (too late!)
- Slider tries to draw with value=0.6, min=1.0 → CRASH
@dimadesu dimadesu force-pushed the camera-zoom-below-1.0 branch from 9db9a89 to d981913 Compare February 7, 2026 04:22
@dimadesu dimadesu changed the title Prevent the crash when the camera reports a zoom ratio < 1.0 (ultra-wide) before the slider range is updated Fix app crash when switching from "BACK 86" camera with zoom slider open and value below 1.0 (on Samsung S25+) Feb 7, 2026
* Handles both Float and Integer (Number) values.
*/
@BindingAdapter("android:value", "android:valueFrom", "android:valueTo", requireAll = true)
fun setSliderValueWithRange(slider: Slider, value: Number?, valueFrom: Number?, valueTo: Number?) {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot how is this used? Will it have any performance impact?

Copy link
Contributor

Copilot AI commented Feb 7, 2026

@dimadesu I've opened a new pull request, #274, to work on those changes. Once the pull request is ready, I'll request review from you.

@dimadesu dimadesu merged commit 0962c0d into main Feb 7, 2026
@dimadesu dimadesu deleted the camera-zoom-below-1.0 branch February 7, 2026 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The app crashes when switching from "BACK 86°" to "BACK 115°" with the zoom button active.

2 participants