Skip to content

Commit

Permalink
iOS18 issues restoring sessions
Browse files Browse the repository at this point in the history
- Found this due to mosh sessions not saving and restoring properly sometimes.
- The UIPageViewController has changed internally when some events are called.
We cannot rely on ViewWillAppear before for certain cases like restoring the
state, so it is now done after the PVC is done with the transition.
  • Loading branch information
Carlos Cabanero committed Sep 16, 2024
1 parent 4bde3a4 commit ec341c6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 5 additions & 0 deletions Blink/Commands/mosh/mosh.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ enum MoshError: Error, LocalizedError {

let stateCallback: mosh_state_callback = { (context, buffer, size) in
guard let buffer = buffer, let context = context else {
//print("Mosh returned with no encoded state.")
return
}
let data = Data(bytes: buffer, count: size)
Expand All @@ -110,12 +111,14 @@ enum MoshError: Error, LocalizedError {
}

@objc public override func main(_ argc: Int32, argv: Argv) -> Int32 {
//print("mosh main")
mcpSession.setActiveSession()
self.currentRunLoop = RunLoop.current
// In ObjC, sessionParams is a covariable for MoshParams.
// In Swift we need to cast.
if let initialMoshParams = self.sessionParams as? MoshParams,
let _ = initialMoshParams.encodedState {
//print("Init mosh from Params")
return moshMain(initialMoshParams)
} else {
let command: MoshCommand
Expand Down Expand Up @@ -241,6 +244,8 @@ enum MoshError: Error, LocalizedError {
}

private func moshMain(_ moshParams: MoshParams) -> Int32 {
//print("moshMain active")

let originalRawMode = device.rawMode
self.device.rawMode = true

Expand Down
2 changes: 2 additions & 0 deletions Blink/SpaceController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,11 @@ extension SpaceController: UIPageViewControllerDelegate {
else {
return
}
termController.resumeIfNeeded()
_currentKey = termController.meta.key
_displayHUD()
_attachInputToCurrentTerm()

}
}

Expand Down
5 changes: 0 additions & 5 deletions Blink/TermController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,6 @@ class TermController: UIViewController {
view.setNeedsLayout()
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated);
resumeIfNeeded()
}

public override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()

Expand Down

0 comments on commit ec341c6

Please sign in to comment.