Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions images/chromium-headful/client/src/components/video.vue
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@
private focused = false
private fullscreen = false
private mutedOverlay = true
private _clipboardPollInterval?: number
get admin() {
return this.$accessor.user.admin
Expand Down Expand Up @@ -533,12 +534,38 @@
this.$client.sendData('keyup', { key: this.keyMap(key) })
}
this.keyboard.listenTo(this._overlay)
/* Chromium-specific clipboard synchronization */
// Sync clipboard when window gains focus
window.addEventListener('focus', () => {
this.syncClipboard()
})
// Sync clipboard on visibility change (when tab becomes active)
document.addEventListener('visibilitychange', () => {
if (!document.hidden) {
this.syncClipboard()
}
})
Copy link

Choose a reason for hiding this comment

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

Bug: Event listeners not removed causing memory leak

The window focus and document visibilitychange event listeners added in mounted() are never removed in beforeDestroy(). This creates a memory leak because the listeners hold references to the component instance, preventing garbage collection. Each time the component is mounted and destroyed, additional listeners accumulate on these global objects.

Fix in Cursor Fix in Web

Copy link
Contributor

Choose a reason for hiding this comment

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

@mateoCuervo i think bugbot has a valid point here

// Polling for clipboard changes while focused (Chromium fallback)
// This ensures clipboard syncs even when staying on the same tab
this._clipboardPollInterval = window.setInterval(() => {
if (this.hosting && this.focused && document.hasFocus()) {
this.syncClipboard()
}
}, 500) // Check every 500ms when active
}
beforeDestroy() {
this.observer.disconnect()
this.$accessor.video.setPlayable(false)
/* Guacamole Keyboard does not provide destroy functions */
// Clean up clipboard polling interval
if (this._clipboardPollInterval) {
window.clearInterval(this._clipboardPollInterval)
}
}
get hasMacOSKbd() {
Expand Down
Loading