HydraIssues

A deliberate Exit experience shows the red Fail panel and 'Session interrupted', because the stop flag never crosses the Objective C to Swift boundary
open bug Project: hydraheadipad Reporter: anonymous 8 Nov 2026 22:21

Description

When deliberatly stopping an experience by clicking 'exit experience' i get this msg whicj makws it seems like a system failde

On ipad-head-cederik

Confirmed and diagnosed, 2026-11-08

The screenshot shows the kiosk error panel with the red fail glyph, the word Fail, and the text: Session interrupted, the connection was lost. A deliberate exit should never reach that state.

The chain

HydraStreamSession.stop ALREADY records that the stop was deliberate:

- (void)stop {
    dispatch_async(dispatch_get_main_queue(), ^{
        if (self.stopRequested) return;
        self.stopRequested = YES;

Both Objective C exit routes go through it. The menu row calls [self stop] directly, and the two second hold reaches returnToMainFrame, whose hydraReturnToMainFrame block also calls [s stop].

The Swift side never asks. StreamSessionBridge.streamSessionDidStop decides only from its own flag:

let wasUserInitiated = userStoppedSession

and userStoppedSession is set only by StreamSessionBridge.stop(), which is the SwiftUI gesture route. So every exit taken from inside the stream view is classified as an unexpected disconnection and routed to onUnexpectedStop, which calls showSessionInterrupted().

stopRequested is declared in a class extension inside HydraStreamSession.m, so it is private and Swift cannot read it. That is why the information exists and never crosses the boundary.

Scope, and a note on timing

This predates the recent work. The exit menu arrived in commit 9dc0226 in the fork. The Keyboard row added for #1149 sits above the Exit experience row and is not involved.

It is likely to be MORE visible from v0.5.2 onward. The two second hold used to abort the application outright, which was #1151. Now that it works, it reaches this same false failure instead. That is an improvement, but it means a second route now lands here.

Second defect in the same string

The message contains an em dash, against the standing rule that no em dash appears in copy or code. A sweep of user facing Swift string literals finds exactly two, this one and one in WireGuardSetupError. Both should go.

Fix

  1. Expose stopRequested as a readonly property on HydraStreamSession.h, keeping the readwrite declaration private in the .m.
  2. In streamSessionDidStop, treat the stop as user initiated when either flag is set:
    let wasUserInitiated = userStoppedSession || session?.stopRequested == true
  3. Remove the em dash from both user facing strings, and soften the wording so a lost connection reads as a lost connection rather than a system failure.

Related

  • #1151 made the two second hold work, so it now reaches this
  • #1149 added the Keyboard row above Exit experience, and is not the cause

Refinement found while writing the fix, and it changed the fix, 2026-11-09

The plan above was to expose stopRequested as readonly and OR it into the Swift decision. That would have been wrong. stopRequested is YES for EVERY route into streamSessionDidStop, because finishStop is only ever reached through stop. Reading it would have made the unexpected branch dead code and hidden three real cases behind a silent return to the grid:

  • ML_ERROR_GRACEFUL_TERMINATION, the host closed the experience. Nobody on the iPad asked for that, so the person must still be told.
  • The inactivity timer expiring.
  • The application going to the background.

So the shipped fix carries the REASON, not the fact of a stop. returnToMainFrame is the single door for every end of stream, wanted or not, so the reason is set before that door.

  1. StreamFrameViewController gains hydraExitWasUserInitiated, set YES in edgeSwiped: (the two second hold) and in streamExitRequested (the controller combination), both immediately before returnToMainFrame.
  2. HydraStreamSession copies it into stopWasRequestedByUser in the hydraReturnToMainFrame block, and sets the same flag directly in the "Exit experience" menu row handler. Readwrite stays private in the .m, readonly on the header, so Swift can read it.
  3. StreamSessionBridge.streamSessionDidStop now reads userStoppedSession || session?.stopWasRequestedByUser.
  4. Genuine errors never reach this code at all. They set terminalError and finishStop calls streamSessionDidFailWithError instead, which was already correct.

Four deliberate routes now classify as wanted: the SwiftUI exit control, the ellipsis menu row, the two second hold, the controller combination. Everything else still reports a failure.

Every stop also names itself in the head log now, with both flags, so the classification can be checked rather than trusted:

Stream: stop classified as wanted (swift gesture false, in stream exit true)
Stream: stop classified as unexpected (swift gesture false, in stream exit false)

The em dash is gone from both user facing strings. The panel now reads "The connection to the experience was lost."

runbook.md gains "Leaving a stream on purpose is not an interruption (issue 1154, v0.5.4+)", with an explicit do-not-simplify-this-to-stopRequested note, and the old "Session interrupted screen appears unexpectedly" entry was corrected because its regression advice pointed at the Swift flag alone. testbook.md gains 10 steps, NOT YET WALKED: 6 for the deliberate routes and 4 that confirm the failure path still fails, which is the half a too broad fix would break.

No unit test. The decision lives inside a UIKit delegate callback and the only pure part of it is an OR, so a test of it would prove nothing. The verification is the testbook, and steps 7 to 9 are the ones that matter.

Shipping as v0.5.4.

Shipped, v0.5.4 build 215, 2026-11-09

VALID in TestFlight. Verified from the release log, not from the step conclusion:

Build 215: VALID
Build is VALID in TestFlight.
  • Tag v0.5.4 on main commit 76b6526, submodule 7f79cae.
  • Validate run 42589447077 on 76b6526: ** BUILD SUCCEEDED **, every regression gate passed, and the action selector gate still reports all 44 selectors at the right arity.
  • Release run 42589936911, no failed steps.

Left OPEN. The fix is live but NOT verified on a device. The 10 testbook steps are still NOT YET WALKED, and steps 7 to 9, the ones that prove a real failure is still reported as a failure, are the ones that would catch a too broad fix. Close this when somebody has walked them on ipad-head-cederik.

Attachments (1)

Attachment