GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(devices): drop the old session's kept frames on a restart · pingdotgg/t3code@1e00ebe

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/client-runtime/src/device
    • stream.test.ts
    • stream.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/client-runtime/src/device/stream.test.ts‎

Copy file name to clipboardExpand all lines: packages/client-runtime/src/device/stream.test.ts
+41Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,47 @@ describe("shared device stream readiness and recovery", () => {
709709
client.stop();
710710
});
711711

712+
it("does not replay the old session's frames when a restart comes during the configuration", async () => {
713+
const { client, sockets, sps, decoders, Decoder, events } = recoveryFixture("android");
714+
let resolveSupport!: (support: { supported: boolean }) => void;
715+
Decoder.isConfigSupported.mockImplementationOnce(
716+
() =>
717+
new Promise((resolve) => {
718+
resolveSupport = resolve;
719+
}),
720+
);
721+
client.start();
722+
await vi.advanceTimersByTimeAsync(0);
723+
sockets[0]!.onopen?.();
724+
// The hub announces the video session.
725+
sockets[0]!.onmessage?.({
726+
data: JSON.stringify({ type: "video-session", size: { width: 400, height: 800 } }),
727+
});
728+
await vi.advanceTimersByTimeAsync(0);
729+
// The key frame starts the decoder configuration.
730+
sockets[0]!.onmessage?.({ data: sps });
731+
await vi.advanceTimersByTimeAsync(0);
732+
expect(decoders).toHaveLength(0);
733+
events.onStatus.mockClear();
734+
// The encoder restarts at the same size while the configuration is pending.
735+
sockets[0]!.onmessage?.({
736+
data: JSON.stringify({ type: "video-session", size: { width: 400, height: 800 } }),
737+
});
738+
await vi.advanceTimersByTimeAsync(0);
739+
// The configuration completes now.
740+
resolveSupport({ supported: true });
741+
await vi.advanceTimersByTimeAsync(0);
742+
// The frame the old session kept is not submitted to the decoder.
743+
expect(decoders[0]!.decode).not.toHaveBeenCalled();
744+
// The first frame timeout still guards the new session.
745+
await vi.advanceTimersByTimeAsync(15_000);
746+
expect(events.onStatus).toHaveBeenCalledWith(
747+
"error",
748+
expect.stringContaining("No video received"),
749+
);
750+
client.stop();
751+
});
752+
712753
it("rebuilds the decoder when the encoder restarts at another size", async () => {
713754
const { client, sockets, sps, decoders, decodedFrame } = recoveryFixture("android");
714755
client.start();
Collapse file

‎packages/client-runtime/src/device/stream.ts‎

Copy file name to clipboardExpand all lines: packages/client-runtime/src/device/stream.ts
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,6 +1339,9 @@ export function createDeviceStreamClient(
13391339
// The frames the old session left in the decoder arrive before the
13401340
// new session's first frame, so they belong to the old one.
13411341
staleFrames = queuedFrames;
1342+
// The frames kept for a pending configuration belong to the old
1343+
// session too, and the new one brings its own key frame.
1344+
pendingSequence = [];
13421345
}
13431346
awaitingKeyframe = true;
13441347
connecting();

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.