Repository navigation
Make an aborted or failed exposure survivable - #10
Open
totoantibes wants to merge 14 commits into
Open
totoantibes wants to merge 14 commits into
totoantibes wants to merge 14 commits into
Conversation
… view
Short exposures taken one after another leave the camera reporting
capturing (1) and never leaving it. Every later start is then refused,
and because native cancel is off by default nothing clears the state:
the camera has to be disconnected and reconnected to take another frame.
Observed on an a7S flat run. The exposure search that chose the time
succeeded at 0.0078s and 0.0157s, then the capture run wedged on its
first frame at 0.01174s. The difference is spacing, not exposure: the
search's steps were seconds apart because each one is a round trip,
while the capture run issues frames back to back.
08:09:30.88 Starting Exposure - 0.01174s
08:09:31.01 Capture status created (0) -> capturing (1)
... 20s ...
08:09:50.92 AbortExposure requested; native cancel unavailable
08:09:50.94 Camera Timeout - did not set image as ready
08:09:51.02 Cannot start exposure: camera still busy (capturing (1))
Two changes, both off unless asked for:
MinCaptureIntervalMs enforces a quiet gap after a capture ends before
the next one starts. Default 0, because the gap a camera needs has to
be measured rather than assumed. The wait happens outside captureLock
so a concurrent abort is not downgraded to a soft cancel for its
duration.
A busy status at start now gets one live-view attempt before being
rejected. Live view is a read the driver already supports and clears
the stuck state in practice, where the native cancel that would
otherwise be needed crashes the driver. The status is re-read
afterwards, so a capture that is genuinely still running is rejected
exactly as before.
Both reach the hardware through delegates, so CaptureController stays
testable without a camera: the clock is a TimeProvider and the wait is
an injected sleep, letting the tests assert the gap rather than wait it
out.
Verified: 92 CaptureController tests, 24 temperature, 15 integration,
all passing; plugin builds with 0 errors and only the pre-existing
NU1701 legacy-package warnings. Not yet run against a camera.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VA3wkVae3G3PSxPpxioG9d
The gap existed to stop back-to-back short exposures wedging the camera, but it was charged to every capture. On a 30s sub that is a seventh of the night spent waiting for a camera that has already had thirty seconds of quiet. An exposure at least as long as the gap now skips it. The wedge is a short-exposure failure - flats and bias - so the wait falls there and light frames are untouched. That makes a non-zero default safe, so the guard is on at 4s rather than off. The number is deliberately generous rather than measured: it costs nothing on a light frame and a few seconds across a flat run, against a wedged camera costing the whole sequence and a reconnect. Set it to 0 to disable, or lower once a camera's real threshold is known. Two existing tests used a 1s exposure and so no longer wait; they now use 0.01s, which is the case the guard is for. Added three covering the rule itself: longer than the gap, exactly the gap, shorter than the gap. Verified: 95 CaptureController tests, 24 temperature, 15 integration, all passing; plugin builds with 0 errors and only the pre-existing NU1701 warnings. Still not run against a camera. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VA3wkVae3G3PSxPpxioG9d
Two corrections after the first deployment.
NINA refused to load the plugin outright:
Version string portion was too short or too long. (Parameter 'input')
The file version had been set to 1.0.0.5.1 purely so this build could be
told apart from the three other 1.0.0.5 builds in NINA's plugin list.
NINA parses it with System.Version, which takes at most four parts, so a
fifth component stops the assembly loading at all. Reverted, with the
constraint recorded next to the attribute so it is not tried again. The
builds are told apart by file size instead.
The guard also logged nothing when it waited, so a loop test could only
be read by doing arithmetic on capture timestamps - which is inference,
not evidence. It now reports the wait it actually performed, and only
when there was one.
Measured on the rig afterwards, 15 consecutive 0.1s exposures: no
"Cannot start exposure", no camera timeout, intervals settling to a
median of 5.80s in a 5.57-5.92s band. That sequence used to wedge on its
first frame and need a reconnect.
The live-view recovery is still unexercised: nothing wedged, which is
what the guard is for, but it means half of this is unproven against
hardware.
Verified: 97 CaptureController tests, plugin builds with 0 errors.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VA3wkVae3G3PSxPpxioG9d
The 4s gap exists to keep the next shutter release off the previous frame's download. It was measured from the wrong event, so it protected nothing. NINA drives a frame through three separate calls, and the plugin handles them in three separate methods: StartExposure runs WaitForQuietGap, WaitUntilExposureIsReady polls until the native status reads Complete, and only then does DownloadExposure call GetLastImage, which is where the 12.4MB actually moves. MarkCaptureEnded was the only setter of the timestamp the gap is measured from, and it fired on Complete -- before a single byte had been transferred. The gap therefore elapsed inside the transfer. Measured on an a7S at 0.0125s with the native driver at log level 2: the retrieval began at 13:08:38.495 and was still being polled at 13:08:42.669, 4.17s later, by which time the 4s gap had already released the next frame. The native driver logs "There's a pre-existing download, attempting to clean up", fires the shutter, and then never reports an Image Buffer Status Update or a Step 4 retrieval for the new frame -- it polls "Nothing yet" every 1.3s forever and only a reconnect clears it. One frame of ten survived a 0.0125s series; a 30s sub always finishes its download long before the next frame and has never wedged. Mark the retrieval in DownloadExposure instead, in a finally because the camera is done either way and a stale timestamp would let the next frame start immediately. The Complete, Cancelled and Failed marks stay as a floor so a frame NINA abandons without downloading still records an end. This does not claim to fix the underlying race in the native driver: the same "pre-existing download" cleanup preceded a frame that succeeded. It stops the plugin handing the camera a shutter release while a download is in flight, which is what the gap was written to do. Tests: the new TheGapIsMeasuredFromTheImageRetrievalNotFromTheExposureEnding fails without the production change (waits 0ms instead of 4000ms), and ALongExposureIsStillNotDelayedOnceTheImageIsRetrieved guards the other direction so lights keep their cadence. 99 tests pass. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VA3wkVae3G3PSxPpxioG9d
Abort has six exits and the log said the same thing for all the ones that matter: "native cancel unavailable; letting capture finish". On the rig today, with native cancel switched ON and the setting confirmed as True in the profile, that line still appeared and the camera wedged - and there was no way to tell from the log whether the setting read had come back false or the capture lock had simply not been free. Both are plausible. WaitUntilReady takes captureLock to poll the driver, and during an exposure that poll goes through the driver's single worker thread, so the poller can hold the lock for long stretches of exactly the window in which a cancel needs it. Guessing between the two would have meant another deploy either way. Abort now reports its reason through an onAbortDecision callback, wired to the NINA log in CameraDriver, naming the setting, the lock timeout or the capture status as the case may be. AbortExposure also logs its outcome for every result rather than only the soft one, since a capture that nothing ever cancels is what turns a lost frame into a lost night. No control flow changed. Test suite: 96 of 99 pass. Three fail, and none of them is caused by this change - two of the three (ConcurrentStartsCannotBothEnterNativeStart, CancellationAfterPollingBeginsInterruptsWaitWithoutAToken) fail identically on a clean tree, and the third (NativeCallsNeverOverlap, which touches nothing in this diff) passed once and failed twice across three identical runs in isolation. They are load-sensitive thread scheduling tests. Leaving them: making them deterministic is a piece of work in its own right and does not belong in a logging change. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VA3wkVae3G3PSxPpxioG9d
With native cancel switched on, an abort got through on one attempt and timed out on the next. The log line added in the previous commit named the cause on its first outing: Abort decision: native cancel is on, but the capture lock could not be taken within 1000ms, so nothing was sent; the status poller holds that lock while it reads the driver. WaitUntilReady held captureLock across getStatus(). It reacquires ten times a second, and during an exposure each read goes through the native driver's single worker thread, so the lock was held for most of the window in which a cancel needs it. Whether an abort reached the camera was luck - and when it lost, the capture stayed outstanding and every later frame was refused until the camera was reconnected. That is the difference the two rig runs showed: at 14:24:14 the cancel went through and the next frame saved 34s later with no reconnect; at 14:26:19 it did not, and nothing worked again until a disconnect. The read is now outside the lock. That is safe because it is a read - the native driver guards its own state, and what captureLock protects here is the decision that the status belongs to OUR exposure. That decision is still taken under the lock, after the read, so a capture that superseded ours mid-read cannot be mistaken for our own ending. The new test pins it deterministically rather than by timing: a gate holds the poller inside getStatus, and the abort raised at that moment must still reach the native cancel. Against the previous code it fails with exactly the production symptom - expected NativeCancelRequested, actual SoftCancelRequested - and it uses a dedicated thread because other tests in this assembly block pool threads for tens of seconds. Suite: 99 of 100 on the last run, 97 of 100 on the one before. The difference is the three load-sensitive tests noted in the previous commit, which come and go on an otherwise unchanged tree; this change's own test passed in both. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VA3wkVae3G3PSxPpxioG9d
The native driver runs one operation at a time, so a start that waits for the camera to release its previous photo holds captureLock for as long as that takes. An abort in that window could not take the lock and was simply dropped: it reported SoftCancelRequested, NINA told the user the camera would finish the frame, and nothing ever cancelled the capture. That is the window where an abort matters most. Measured on the rig today with the previous build: a 20s exposure aborted 6s in logged "the capture lock could not be taken within 1000ms" while the driver reported "busy with another operation" for the next 22 seconds; the capture was never cancelled and all three frames afterwards were refused as "camera is still busy". Abort already records its intent on the request before it tries the lock, so the fix is to honour that record where the lock is already held - at the end of Start, once the native start has returned. The decision itself moves into CancelUnderHeldLock so both callers make it the same way and log the same lines. AbortResult gains NativeCancelDeferred for that case, and the driver logs it without the warning popup: the cancel is being delivered, just not from the aborting thread, so telling the user the camera will finish the exposure would be wrong. AbortDuringBlockedNativeStartReturnsWithoutCallingNativeCancel asserted the old behaviour. What still has to hold is that the abort returns inside its timeout and does not reach into the driver while the start is in flight, so it now asserts that and is named for it. The new test fails against the old code with Cancels 0 instead of 1. 101 of 101 tests pass. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VA3wkVae3G3PSxPpxioG9d
The deferred cancel was delivered and then declined. Measured on the rig 2026-11-03 with the previous build: the abort was correctly deferred at 16:33:17, the native start returned at 16:33:41 after 31 seconds in the driver, and the status read at that moment said 0x0000 - Created - so the "not busy, nothing to cancel" guard sent nothing. Six seconds later the plugin logged "Camera reports a capture still running with nothing of ours in flight" and all three frames afterwards were refused as "camera is still busy". Created is the one idle status that can be a lie. The driver does not move a capture to Capturing until its worker picks it up, so a status read taken immediately after our own native start can still say Created while the shutter is already committed. Cancelled, Complete and Failed are not ambiguous, and the deferred path still keeps its hands off those - as do the unreadable and in-transfer guards, unchanged. Two tests cover it: the Created case, which fails against the old code with Cancels 0 instead of 1, and a theory over the three statuses that must still be left alone. Also fixes the two load-flaky tests, which my new tests pushed over the edge from intermittent to frequent: - CancellationAfterPollingBeginsInterruptsWaitWithoutAToken bounded a Task.Delay continuation at two seconds. It asserts that an abort interrupts the wait, not how fast, so the bound is now 30s. - NativeCallsNeverOverlap fired twelve pool callers into Invoke, which blocks its caller while the work it queued needs a pool thread of its own. Twelve of them starve the pool they are waiting on, the pool injects roughly one thread a second, and the run reached Invoke's 30s timeout. The callers are dedicated threads now. 105 of 105 tests pass, four consecutive full-suite runs, and the suite went from 7-31s to 2-5s. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VA3wkVae3G3PSxPpxioG9d
Cancelling a capture the driver still reports as Created takes NINA down. Measured on the rig 2026-11-03: the deferred cancel went out at 16:56:07.50 with status 0x0000 and the process died in the same second - SonyMTPCamera.dll 1.0.1.25, 0xc0000005 at offset 0x1fd79. The previous commit was wrong to send it, and the guard it relaxed was load-bearing. The driver's reason is in CancelCapture: it frees the capture task and its parameters as soon as Cancel reports success, and while the status is still Created the task has not started reading them. That is a defect in the driver and is worth fixing there; this commit stops the plugin walking into it. So the deferred cancel now waits for the status to tell the truth and then decides exactly as it always did - every guard back as it was. The wait is bounded at ten seconds and ends the moment the capture appears, and if it never appears nothing is sent. Blocking there is acceptable: NINA has already abandoned the frame, and each status read is itself a queued native call. Both halves are covered: one test proves the wait finds a capture announced on the third read and cancels it, the other proves a capture that is never announced is never cancelled. Both fail without the wait. 106 of 106 tests pass, three consecutive full-suite runs. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VA3wkVae3G3PSxPpxioG9d
Cancelling a capture does not close a shutter the camera has already opened, and the shutter speed cannot be changed while it is open. So the next capture's exposure-time change fails, the plugin refuses to shoot at the wrong shutter - correctly - and that refusal leaves NINA believing an exposure is still running, after which it drops every later capture request without logging anything at all. That is the whole of what was left after an abort. Measured on the rig 2026-11-03 with driver 1.0.1.26, which cancels cleanly: a 20s exposure was cancelled 105ms after the shutter opened at 17:28:30.3, the next frame was attempted at 17:28:38.6 and gave up at 17:28:51.5 reporting "camera reports 0x00C8000A" - 20s, the shutter still open. The camera freed itself around 17:28:50.3, one second before the attempt expired. The two frames after it were never logged as starting. So the next start now waits for the cancelled exposure to finish. The bound is that exposure's own length, so it costs nothing that was not already being spent, and only a cancel that was actually sent arms it: a frame that ended by itself has already put its image down, and an abort that sent nothing never interrupted anything. The wait is reported on its own log line rather than the quiet gap's. Two different reasons to wait that the log could not tell apart is what made this fault take as long as it did. The timestamp is taken after the native start returns, because that call changes the exposure time first - walking the camera's shutter ladder from 1/80 to 20s is about thirty seconds of stepping, and the exposure only begins once it is done. That stepping is also what the deferred abort has been waiting through all along. 109 of 109 tests pass. The new test fails without the wait. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VA3wkVae3G3PSxPpxioG9d
… latches This is the gap that ended the night of 2026-11-03. At 23:23 an exposure stopped announcing its image. The abort worked correctly, the sequence's error behaviour is ContinueOnError, so NINA started another, which failed the same way - every 50 seconds for twenty minutes. Around 23:44 a native call finally exceeded NativeCallExecutor's 30s timeout, which latches the driver dead for the rest of the process. After that the camera could not even be enumerated, so a reconnect could no longer have recovered the session even once the body came back. Two changes, and the second matters more than the first. A failed exposure now makes the next start reopen the camera first. A close and reopen is the only recovery that has ever cleared this body: it was done by hand three times on 2026-11-03 and worked every time, including on a capture the camera was holding open. The swap happens inside the connection lock, so NINA never sees the camera as disconnected - a camera it believes has dropped ends the sequence, which is the opposite of the point. It is attempted once per failed exposure rather than in a loop, and a reopen that fails or throws still lets the exposure run: it is an attempt, not a precondition. After MaxConsecutiveCaptureFailures exposures in a row deliver nothing - three by default - the plugin stops driving the camera at all. The frames are lost either way; what this protects is the driver. Refusing makes no native calls, so the executor cannot latch, and one reconnect at any later time brings the whole session back instead of none of it. An image coming off the camera is the only thing that clears the count, which is why MarkCaptureSucceeded is separate from MarkImageRetrieved - that one times the quiet gap and runs even when the retrieval threw. NINA's download timeout and a user abort are indistinguishable at the plugin's cancellation path, so both count. A user abort therefore costs one reopen, which is harmless. 116 of 116 tests pass. Five of the new ones fail without this change. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VA3wkVae3G3PSxPpxioG9d
Measured on the rig 2026-11-04, minutes after the previous commit. The
reopen itself worked exactly as designed:
10:14:14 WaitUntilExposureIsReady cancelled
10:14:30 Waited 12110ms for a cancelled exposure to finish
10:14:32 Camera recovery: reopened the camera after 1 failed exposure(s)
and then the exposure that followed it never delivered an image:
10:15:12 Camera Timeout - Camera did not set image as ready after
exposuretime + 20 seconds
The same abort-then-reshoot, on the previous build without the reopen,
landed three frames out of three on two consecutive runs earlier the same
morning. So the reopen costs the frame it exists to save. Something about
a freshly reopened handle stops the next capture delivering - the plugin's
cached shutter ladder and camera settings belong to the old handle, which
is the first thing to check - and until that is understood this must not
run.
EnableCameraReopenOnFailure defaults to false. The code and its tests stay,
so the investigation has something to work from.
The failure cap is untouched and stays on. It is the half that cannot have
this problem, because refusing to start makes no native calls at all, and
it is the half that protects the driver from the 30s timeout that latched
it dead and made last night unrecoverable.
116 of 116 tests pass.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VA3wkVae3G3PSxPpxioG9d
…ody tried The cap as shipped was a trap rather than a guard. Only an image coming off the camera cleared the count, and once the cap refused every start no image could be taken, so the camera stayed refused until NINA restarted. Measured on the rig 2026-11-04: the cap tripped at 10:31:29, a full disconnect and reconnect followed at 10:34:44, and the next start was still refused. The claim in the previous commit that one reconnect brings the session back was simply false. Connect now clears the count. A reconnect is the operator - or a recovery trigger - saying try again, and it is also the only thing that has ever cleared this body, so it gets a clean slate. Also: a disabled reopen now reports nothing instead of "could not reopen the camera", which read as a failed attempt when nothing was attempted. The controller asks whether recovery is enabled before invoking the callback rather than letting the callback answer false. That phrasing is the same dishonest-status trap this plugin has spent the week removing. 118 of 118 tests pass. Note what they do and do not cover: ResetFailureCount is tested directly, but nothing here proves Connect calls it - CameraDriver needs NINA's services to construct, so that wiring is verified on the rig, not in the suite. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VA3wkVae3G3PSxPpxioG9d
NINA died twice on the rig 2026-11-04 while connecting to a camera that
had stopped functioning - 11:57:56 and 12:09:40, both an access violation
inside coreclr.dll at the same fault offset 0x3596cf. An AV in the managed
runtime means the heap was already corrupt before the fault, and the
driver log says what the camera was doing at the time:
Failed executing GetErrorValue (hr = x8007001f) ERROR_GEN_FAILURE
Unable to read WORD value as it would extend beyond end of data
Unable to read DWORD value as it would extend beyond end of data
Unable to read DWORD value as it would extend beyond end of data
GetPropertyList is where that becomes corruption. It is a size-then-fill
native call with three defects, all of which need the camera to answer
with nonsense before they matter:
- (int)listSize * sizeof(UInt32) overflows for a large count, so the
allocation can be far smaller than the copy that follows.
- listSize is passed by reference to the second call as well, so the
camera can report more than was allocated and Marshal.Copy runs off
the end of the buffer.
- the buffer leaks on both throw paths.
Now: the probed count is rejected above a generous bound, the second call
gets its own copy of the size so the allocation it is measured against
cannot change underneath, the copy is clamped to what was allocated, and
the free is in a finally. GetPropertyValueOptions gets the same bound,
because that loop is driven by a count from the camera too and can
otherwise fire millions of native calls at a device that is not
answering.
The bounds are 4096, which is two orders of magnitude above what an a7S
advertises. They exist to catch nonsense, not to constrain real hardware.
A camera in this state should fail to connect with a message naming the
cause. It should not take the host process down.
118 of 118 tests pass, though none of them reach this code: it P/Invokes
the DLL directly and there is no seam. Verification is on the rig, which
currently reproduces the crash deterministically.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VA3wkVae3G3PSxPpxioG9d
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.
Fourteen commits from two nights of unattended imaging with an a7S (ILCE-7S), where a single lost frame repeatedly became a lost session. Everything here is measured on hardware; the parts that are not, I have said so.
Please read the history note at the bottom before reviewing commit by commit. Several commits supersede each other.
The abort never reached the camera
Three separate reasons, found one at a time:
WaitUntilReadyheldcaptureLockacross the status read. The poller reacquires it ten times a second and each read goes through the driver's single worker thread, so during an exposure the lock was held for most of the window a cancel needs it. Whether an abort reached the camera was a coin toss — one in two on the rig, with the log readingthe capture lock could not be taken within 1000ms.0x0000at 17:28:30, declined, and six seconds later the plugin found a capture still running. It now waits, bounded, for the capture to be announced. Cancelling into Created instead was tried and took the host down —SonyMTPCamera.dll0xc0000005— so the wait is deliberate.The frame after an abort could not be taken
Cancelling does not close a shutter the camera has already opened, and the shutter speed cannot be changed while it is open. So the next capture's exposure-time change failed, the plugin correctly refused to shoot at the wrong shutter, and that refusal left the host believing an exposure was still running, after which it dropped every later capture request silently.
The next start now waits for a cancelled exposure to finish on the camera. The bound is that exposure's own length, so it costs nothing that was not already being spent.
A failure loop ground the driver to death
The fault that actually ended a night. An exposure stopped announcing its image; error behaviour was ContinueOnError, so the host started another, which failed the same way, every 50 seconds for twenty minutes. Then a native call exceeded
NativeCallExecutor's 30s timeout, which latches the driver dead for the rest of the process — after that the camera could not even be enumerated, so a reconnect could no longer recover the session.After
MaxConsecutiveCaptureFailuresexposures in a row deliver nothing (3 by default, 0 disables) the plugin stops driving the camera. The frames are lost either way; what this protects is the driver. Refusing makes no native calls, so the executor cannot latch, and a reconnect clears the count.A malfunctioning camera could corrupt the heap
GetPropertyListis a size-then-fill call whose count comes from the camera.(int)listSize * sizeof(UInt32)overflows for a large count; the size is passed by reference to the fill call as well, so the camera can report more than was allocated andMarshal.Copyruns off the end; and the buffer leaks on both throw paths.Measured: the camera answered
ERROR_GEN_FAILURE, the driver loggedUnable to read WORD/DWORD value as it would extend beyond end of datathree times, and the host died with an access violation insidecoreclr.dll— twice, at the same fault offset. The count is now bounded, the fill call gets its own copy of the size, the copy is clamped to the allocation, and the free is in afinally.Quiet gap between captures
Back-to-back short exposures wedge this body. The gap is timed from the image coming off the camera, not from the exposure completing — those are two different moments and the retrieval is the one that matters. Only exposures shorter than the gap wait, so light frames are unaffected.
Tests
118 pass. The capture-coordination logic is tested independently of NINA and the DLL, including the lock race, the deferred cancel, the Created wait, the aborted-exposure wait and the failure cap — each with a test that fails without its fix.
Two things are not covered, and I would rather say so than imply otherwise:
Connectclearing the failure count (CameraDriverneeds NINA's services to construct, so that wiring was verified on the rig), and theGetPropertyListhardening (it P/Invokes the DLL with no seam; verified against a camera that reproduced the crash deterministically).One change is off by default
EnableCameraReopenOnFailurereopens the camera after a failed exposure. The reopen itself works, and then the next capture does not deliver — the same frame landed three times out of three without it. The cause is now pinned down: reconnecting while the camera holds an undownloaded frame breaks the next capture, which is exactly the moment this fires. The code and tests stay so the investigation has something to work from, but it does not run.History note
This is honest rather than tidy history.
4a8050cshipped a change that crashed the rig and860b6b6corrected it;af12636added the reopen and5cc79a5turned it off;d898350fixes a cap thataf12636made inescapable. Each commit message carries the measurement that prompted it, which is why I have not squashed them. Happy to rebase into three or four commits if you would prefer that for review.🤖 Generated with Claude Code
https://claude.ai/code/session_01VA3wkVae3G3PSxPpxioG9d