solve_global_scene: treat MP_MAXITER as calibration failure#354
Merged
bl4ckb0ne merged 1 commit intocollabora:masterfrom Mar 23, 2026
Merged
Conversation
rocketmark
pushed a commit
to rocketmark/libsurvive
that referenced
this pull request
Mar 13, 2026
bl4ckb0ne
requested changes
Mar 20, 2026
Collaborator
bl4ckb0ne
left a comment
There was a problem hiding this comment.
Missing Assisted-by tag to the commit message. You can also drop the Fix: part.
MP_MAXITER (return code 5) means the solver exhausted its iteration budget without converging. The current code treats this as success (res <= 0 is false), so the unconverged — and potentially wrong — lighthouse positions are written to disk via survive_recording and the GSS result is accepted. On the next launch those positions are loaded as the starting point for calibration. If the unconverged solve is significantly wrong, all subsequent tracking is corrupted and the only recovery is to delete config.json. Adding res == MP_MAXITER to the failure condition rejects unconverged GSS solves the same way as explicit solver errors. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
748a039 to
a8cd1ab
Compare
Contributor
Author
|
Changes made. |
bl4ckb0ne
approved these changes
Mar 23, 2026
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.
Summary
solve_global_sceneusesres <= 0to detect solver failure, butMP_MAXITER(return code 5) is not ≤ 0. When the GSS solver hits its iteration limit without converging,status_failureis false, the unconverged lighthouse positions are accepted, and they are written to disk.On the next launch those positions are loaded as the starting point for calibration. If the unconverged solve is significantly wrong, all subsequent tracking is corrupted and the only recovery is to delete
config.json.Demonstration
BEFORE fix:
GSS solver hits iteration limit
res = MP_MAXITER (5)
res <= 0 → false
status_failure = false
Unconverged lighthouse positions written to disk
Next launch: loads bad positions → tracking corrupted
Result: config.json must be deleted to recover
AFTER fix:
GSS solver hits iteration limit
res = MP_MAXITER (5)
res <= 0 || res == MP_MAXITER → true
status_failure = true
GSS result discarded, existing positions preserved
Result: calibration retried on next GSS cycle
The regular per-object pose solver (line ~522) already rejects
res <= 0correctly;solve_global_scenewas missing theMP_MAXITERcase.Impact
Any deployment that triggers GSS calibration (lighthouse position solving) is exposed. The failure mode is silent. No crash, no warning, but tracking quality degrades permanently until config is cleared. More likely on resource-constrained hardware (embedded, Pi) where the solver may not converge within the default iteration budget.
Change
One line in
src/poser_mpfit.c, insidesolve_global_sceneonly. The per-object pose solver is not touched.Found via
Observed in production: GSS calibration would occasionally produce wildly wrong lighthouse positions that persisted across restarts. Correlating with solver return codes showed
MP_MAXITERreturns were being silently accepted. Deletingconfig.jsonrecovered tracking; addingres == MP_MAXITERto the failure condition prevented recurrence.