Skip to content

Comments

optimize VNC screen capture and improve keyboard handling#9

Merged
vlad-terin merged 2 commits intobaryhuang:mainfrom
vlad-terin:screenshotimprovement
Apr 1, 2025
Merged

optimize VNC screen capture and improve keyboard handling#9
vlad-terin merged 2 commits intobaryhuang:mainfrom
vlad-terin:screenshotimprovement

Conversation

@vlad-terin
Copy link
Collaborator

I've made several optimizations to improve the screen capture performance:

  1. Incremental Updates:

    • Added support for incremental updates by storing the last frame
    • Only sends changes since the last frame instead of the entire screen
    • This significantly reduces network traffic and processing time
  2. Optimized Socket Reading:

    • Implemented a new _recv_exact method for efficient socket reading
    • Increased socket buffer size to 8192 bytes for better throughput
    • Uses buffered reading to reduce the number of socket calls
  3. Image Processing Optimizations:

    • Added PNG compression optimization with quality=95
    • Reuses image objects when possible
    • Removed unnecessary error rectangles and debug logging
  4. Error Handling Improvements:

    • Better error detection and handling
    • Early returns on critical failures
    • More informative error messages

You should notice:

  • Faster initial screen capture
  • Much faster subsequent captures (due to incremental updates)
  • Lower CPU usage
  • Reduced network traffic

@baryhuang baryhuang self-requested a review April 1, 2025 04:36
Copy link
Owner

@baryhuang baryhuang left a comment

Choose a reason for hiding this comment

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

I tested locally. It's working great! Thank you for the great improvement.

Feel free to merge any time.

@vlad-terin vlad-terin merged commit c28379c into baryhuang:main Apr 1, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants