Skip to content

[v16] Refactor client canvas and fix a race condition when closing RDP stream #52868

Merged
gzdunek merged 7 commits intobranch/v16from
gzdunek/backport-52431/v16
Mar 7, 2025
Merged

[v16] Refactor client canvas and fix a race condition when closing RDP stream #52868
gzdunek merged 7 commits intobranch/v16from
gzdunek/backport-52431/v16

Conversation

@gzdunek
Copy link
Copy Markdown
Contributor

@gzdunek gzdunek commented Mar 6, 2025

Backport #52431 to branch/v16
Backport #52714 to branch/v16

There were some conflicts, I tested the branch manually.

changelog: Resolved an issue where desktop session recordings could have incorrect proportions
changelog: Resolved an issue that could cause WebSocket errors to appear after the graceful shutdown of a desktop session

gzdunek added 3 commits March 6, 2025 18:24
* Remove non-canvas related listeners from `TdpClientCanvas`

* Simplify event handlers setup by using React handlers

* Listen to canvas resize events instead of window ones

* Expose imperative API to set pointer

* Expose imperative API to render frames

* Expose imperative API to change canvas resolution

Also, we no longer need to set the canvas size manually; it is now handled by `objectFit: scale-down`.

* Remove duplicate player shutdown

* Expose imperative API to clear canvas

* Remove unnecessary display size syncing

We get the canvas resolution from the server, there doesn't seem to be a need to calculate it from the browser window size.

* Fix focusing canvas

It didn't work because it happened too early, before we even showed the MFA dialog which stole focus.
This is a temporary fix, I will do it more elegantly in the future.

* Minor code changes

Remove component memoization, it didn't work anyway and doesn't seem needed. We don't have anything particularly expensive to render here from React's perspective.

* Add a TODO for improving rendering functions

(cherry picked from commit 671475f)
…tream (#52714)

* Add `useListener` hook that makes subscribing to events easier

* Expose simpler APIs for subscribing to events

* Replace verbose `useEffect` listeners with `useListener` calls

* Fix a race condition that caused TDP errors to be overwritten with websocket close messages

* Move `clientOnTdpWarning` to `DesktopCanvas.tsx`

* Move `clientOnTdpInfo` to `DesktopCanvas.tsx`

* Move `clientOnTdpError` to `DesktopCanvas.tsx`

* Move functions that change WS connection status to `DesktopCanvas.tsx`

* Change order of functions

* Do not remove listeners when shutting down the WebSocket

It's the responsibility of callers who created the listeners to clean them up.
Otherwise, `onWsClose` callback won't be called when we call `shutdown()`.

* Fix types

(cherry picked from commit 0a7d941)
@gzdunek
Copy link
Copy Markdown
Contributor Author

gzdunek commented Mar 6, 2025

Snapshot test were failing for the Desktop Session story. Since we removed snapshots completely in v17, I have removed the failing one here as well.

@gzdunek gzdunek enabled auto-merge March 7, 2025 08:55
@gzdunek gzdunek added this pull request to the merge queue Mar 7, 2025
Merged via the queue into branch/v16 with commit cf46ec7 Mar 7, 2025
43 checks passed
@gzdunek gzdunek deleted the gzdunek/backport-52431/v16 branch March 7, 2025 16:02
@fheinecke fheinecke mentioned this pull request Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants