Skip to content

[v17] Add latency detector for desktop sessions (#52827)#54604

Closed
probakowski wants to merge 3 commits intobranch/v17from
probakowski/backport-52827-branch/v17
Closed

[v17] Add latency detector for desktop sessions (#52827)#54604
probakowski wants to merge 3 commits intobranch/v17from
probakowski/backport-52827-branch/v17

Conversation

@probakowski
Copy link
Copy Markdown
Contributor

@probakowski probakowski commented May 7, 2025

Backports #52827 to branch/v17
The differences between this and master version are logging and fix for goroutines leak that I'll add to master in separate PR

changelog: Add latency detector for desktop sessions

probakowski and others added 2 commits May 7, 2025 17:34
* wip

* add ping message and latency from desktop side

* version

* Fix backward compatibility

* godocs

* formatting

* fix imports

* formatting

* formatting

* log and gci

* lint

* Apply tooltip on the icon directly, instead of on the Menu component

This fixes a problem where onMouseLeave in HoverTooltip wasn't called and the tooltip didn't disappear.

* Use consistent spacing between top bar elements

* updates from origin

* e

* e

* lint

* rework UI after merge

* Rename fields in backend

* prettier

* Update web/packages/shared/components/DesktopSession/TopBar.tsx

Co-authored-by: Grzegorz Zdunek <gzdunek@users.noreply.github.com>

* review comments

* fix ui

* add env var to disable windows desktop "ping"

* review comment

* review comment

* Update lib/web/desktop.go

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>

* Refactor latency monitoring

* fix spelling

* remove monitorSessionLatency

* gci

* review comment

* review comment

* Update RFD and version

* fix gaps

---------

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
Co-authored-by: Grzegorz Zdunek <grzegorz.zdunek@goteleport.com>
Co-authored-by: Grzegorz Zdunek <gzdunek@users.noreply.github.com>
@probakowski probakowski requested a review from espadolini May 8, 2025 22:23
Copy link
Copy Markdown
Contributor

@espadolini espadolini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The concurrency bugs around the handling of ping and latency report messages are likely a result of needless complexity, I would recommend taking a step back and rethinking of what should happen and when, and to try to make that happen with fewer moving parts.

conn.Close()
}
}
if err := c.cfg.Conn.WriteMessage(m); err != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will unsynchronously write into an io.ReadWriteCloser - which is contractually not safe for concurrent write - that's set from a net.Conn, which is safe for concurrent writes from a concurrency standpoint, but with utterly meaningless results (if any of the concurrent writes is larger than one byte) since there's no telling if the underlying writes are split and in which order the bytes are going to be jumbled on the wire.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The writer in question is *tls.Conn which is thread safe (internally guarded by mutex), so it wouldn't be a problem here. Could you check #54795 where I added same guard in tdp.Conn so any io.ReadWriteCloser can work here (I simplified other parts of code, too)

Comment thread lib/web/desktop.go
errs.Go(func() error {
for {
select {
case msg := <-tdpMessagesToSend:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goroutine running the monitorLatency callback can get stuck on tdpMessagesToSend when this loop exits.

@probakowski
Copy link
Copy Markdown
Contributor Author

Already merged in different PR

@probakowski probakowski closed this Jun 3, 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