Skip to content

[v17] Refactor client canvas and fix a race condition when closing RDP stream #52866

Merged
gzdunek merged 2 commits intobranch/v17from
gzdunek/backport-52431/v17
Mar 7, 2025
Merged

[v17] Refactor client canvas and fix a race condition when closing RDP stream #52866
gzdunek merged 2 commits intobranch/v17from
gzdunek/backport-52431/v17

Conversation

@gzdunek
Copy link
Copy Markdown
Contributor

@gzdunek gzdunek commented Mar 6, 2025

Backport #52431 to branch/v17
Backport #52714 to branch/v17

Clean backports, no conflicts.

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 2 commits March 6, 2025 18:18
* 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 gzdunek added this pull request to the merge queue Mar 7, 2025
Merged via the queue into branch/v17 with commit 65c1d2b Mar 7, 2025
45 checks passed
@gzdunek gzdunek deleted the gzdunek/backport-52431/v17 branch March 7, 2025 08:53
@camscale camscale mentioned this pull request Mar 19, 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