fix: Apply adaptiveness metering modes before resolving focusTo(…)#4088
Open
mrousavy wants to merge 1 commit into
Open
fix: Apply adaptiveness metering modes before resolving focusTo(…)#4088mrousavy wants to merge 1 commit into
adaptiveness metering modes before resolving focusTo(…)#4088mrousavy wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
mrousavy
commented
Jul 23, 2026
Comment on lines
+162
to
+163
| // Update AE/AF/AWB to locked or continuous tracking *before* resolving, | ||
| // so callers observe the final modes as soon as the Promise resolves. |
Owner
Author
There was a problem hiding this comment.
Suggested change
| // Update AE/AF/AWB to locked or continuous tracking *before* resolving, | |
| // so callers observe the final modes as soon as the Promise resolves. | |
| // Update AE/AF/AWB to locked or continuous tracking to complete the metering task |
| ) | ||
| onComplete?() | ||
| isFinished = true | ||
| destroy() |
Owner
Author
There was a problem hiding this comment.
If we add a debug only assert to update() to ensure it is only ever called from the same queue via Dispatch Specific, then we can move these two lines down just above onComplete?() (line 170 now) again to make the code easier to read? not sure if needed 100% tbh, but it felt weird to see isFinished = true, and then some more actual logic (switch adaptivenes { ...}) after that - reads like it isn't finished after all or has an intermediate state then.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the Harness iOS failure on
mainintroduced with the test from #4078 (locks metering modes after focusTo with locked adaptiveness,expected 'continuous-auto-white-balance' to be 'locked').Root cause: In
MeteringTask.update(), once all metering states settled,onComplete?()resolved the JS Promise beforesetMeteringValuesToLocked()/...Continuous()applied the final modes. The JS continuation's synchronouscontroller.whiteBalanceModeread raced ahead of the camera queue'slockForConfiguration()+ mode set and still sawcontinuous-auto-white-balance. The AF/AE asserts masked this because snappy metering uses one-shot.autoFocus/.autoExpose, which AVFoundation auto-transitions to.lockedon settle - AWB running in continuous mode only becomeslockedthrough the explicit (late) set. This failed identically on #4078's own CI run, so it lost the race deterministically on the CI iPhone.Fix: Reorder the completion sequence: mark
isFinished, tear down KVO observers/timers, apply theadaptivenessmodes, then resolve the Promise.isFinishedis set first sodestroy()doesn't fireonErrorand queued KVO callbacks bail out; observers are invalidated before the mode mutation so setting.lockedcan't re-enter the settle tracking.Android needs no change - it bakes the locking mode into the CameraX
FocusMeteringActionviasetLockingMode(...)before starting, so the lock is already part of the action when its Promise resolves.🤖 Generated with Claude Code