Skip to content

Commit ec341c6

Browse files
author
Carlos Cabanero
committed
iOS18 issues restoring sessions
- 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.
1 parent 4bde3a4 commit ec341c6

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

Blink/Commands/mosh/mosh.swift

+5
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ enum MoshError: Error, LocalizedError {
8686

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

112113
@objc public override func main(_ argc: Int32, argv: Argv) -> Int32 {
114+
//print("mosh main")
113115
mcpSession.setActiveSession()
114116
self.currentRunLoop = RunLoop.current
115117
// In ObjC, sessionParams is a covariable for MoshParams.
116118
// In Swift we need to cast.
117119
if let initialMoshParams = self.sessionParams as? MoshParams,
118120
let _ = initialMoshParams.encodedState {
121+
//print("Init mosh from Params")
119122
return moshMain(initialMoshParams)
120123
} else {
121124
let command: MoshCommand
@@ -241,6 +244,8 @@ enum MoshError: Error, LocalizedError {
241244
}
242245

243246
private func moshMain(_ moshParams: MoshParams) -> Int32 {
247+
//print("moshMain active")
248+
244249
let originalRawMode = device.rawMode
245250
self.device.rawMode = true
246251

Blink/SpaceController.swift

+2
Original file line numberDiff line numberDiff line change
@@ -583,9 +583,11 @@ extension SpaceController: UIPageViewControllerDelegate {
583583
else {
584584
return
585585
}
586+
termController.resumeIfNeeded()
586587
_currentKey = termController.meta.key
587588
_displayHUD()
588589
_attachInputToCurrentTerm()
590+
589591
}
590592
}
591593

Blink/TermController.swift

-5
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,6 @@ class TermController: UIViewController {
236236
view.setNeedsLayout()
237237
}
238238

239-
override func viewWillAppear(_ animated: Bool) {
240-
super.viewWillAppear(animated);
241-
resumeIfNeeded()
242-
}
243-
244239
public override func viewWillLayoutSubviews() {
245240
super.viewWillLayoutSubviews()
246241

0 commit comments

Comments
 (0)