Skip to content

GUACAMOLE-2338: Add opt-in fast lossless RGB PNG encoding - #721

Open
JohnXu22786 wants to merge 10 commits into
apache:mainfrom
JohnXu22786:perf/opt-in-fast-lossless-png
Open

JohnXu22786 wants to merge 10 commits into
apache:mainfrom
JohnXu22786:perf/opt-in-fast-lossless-png

Conversation

@JohnXu22786

@JohnXu22786 JohnXu22786 commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does

Before this PR:

RDP and VNC connections had no per-connection option for a faster lossless PNG path for opaque RGB24 images. PNG stream wrappers also did not report encoder write failures to the client or user.

After this PR:

Adds a default-off fast-png connection option for RDP and VNC. When the owning connection enables it, opaque RGB24 surfaces use an internal truecolor PNG writer with low compression effort and the SUB filter. Decoded pixels remain lossless; the existing default encoding and non-RGB24/alpha fallback remain in place.

PNG write failures now abort the client or user stream instead of marking a truncated image complete. The change includes public API documentation, failure-injection tests, and an optional reproducible encoder benchmark.

Type of change

Experimental opt-in performance feature and PNG error-handling fix.

Validation and limitations

  • make -C src/libguac followed by make -C src/libguac/tests check: 96/96 tests passed.
  • make -C src/libguac/tests png-benchmark: 1280x720 RGB24 inputs, two warmups and seven alternating timed samples per encoder. Reported bytes include Guacamole blob framing, not network I/O.
    • Four-color tiles: default 2,693 bytes / 6,406 µs; fast 31,228 bytes / 4,185 µs (1.53x).
    • Gradient/text: default 31,656 bytes / 25,431 µs; fast 106,210 bytes / 5,881 µs (4.32x).
    • Fixed-seed noise: default 3,701,790 bytes / 104,712 µs; fast 3,701,766 bytes / 63,179 µs (1.66x).
  • The faster path can substantially increase output size for low-color images. These are local encoder measurements; no network or end-to-end FPS gain is claimed.

Breaking changes

None.

Jira

GUACAMOLE-2338: Provide an opt-in faster lossless encoding path for opaque RGB24 PNG images

@necouchman

Copy link
Copy Markdown
Contributor

Thanks @JohnXu22786 - a couple of notes for you:

  • All pull requests must have a Jira issue created for them and have the pull request and commit messages tagged with the Jira issue. You can see plenty of examples of this in other pull requests, and you can request a Jira account but going to the following page and clicking the Request Account link at the top of the page: https://issues.apache.org/jira/projects/GUACAMOLE/issues
  • You don't need to submit as a draft to prevent it from being merged - we do not automatically merge pull requests, there will be a review and some changes requested, most likely, before it is merged. Please mark it as "Ready for review" when you actually want it reviewed, else it will probably not get much attention.

You can see the full list of contribution guidelines here: https://guacamole.apache.org/open-source/

@JohnXu22786

JohnXu22786 commented Oct 4, 2026 via email

Copy link
Copy Markdown
Contributor Author

Reduce PNG compression work for opaque RGB24 updates while preserving the existing codec selection and default encoder. The opt-in path trades compression effort for encoding speed without changing decoded pixels.\n\nAdd six production-path pixel round trips covering transparency fallback, odd dimensions, padded strides, and conservative option values.\n\nTracks GUACAMOLE-2338; the environment-variable interface and performance/bandwidth trade-off remain proposed for discussion.
@JohnXu22786
JohnXu22786 force-pushed the perf/opt-in-fast-lossless-png branch from 80bf82f to 9488ad0 Compare October 7, 2026 04:26
@JohnXu22786 JohnXu22786 changed the title Add opt-in fast lossless RGB PNG encoding GUACAMOLE-2338: Add opt-in fast lossless RGB PNG encoding Oct 7, 2026
@JohnXu22786
JohnXu22786 marked this pull request as ready for review October 7, 2026 05:38

@necouchman necouchman left a comment

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.

Thanks, @JohnXu22786, I've a couple of more issues with this:

  • We generally do not use getenv() throughout the code for configuring guacd, and I'm not sure that this feature warrants that sort of change. Is there some reason why using the getenv() method is preferable to something like a command line flag or configuration file directive?
  • Is there any value in making this opt-in flag a per-connection parameter that could be requested by a client for a specific connection?
  • Your code needs to follow established style - in particular, you need to properly document the code. Most of the functions you've added are missing documentation, and the one that has it doesn't have complete documentation (missing @PARAM and @return tags).

…c API

Remove getenv(), preserve the existing legacy encoder API, and pass an explicit connection option through client and user PNG streams. Document fast writer parameters and return value.
Parse fast-png through existing Guacamole handshake settings and propagate only the owner's setting to the shared connection. Default remains disabled; joining users cannot override it.
Replace environment mutation with per-invocation option testing, preserve legacy/default and alpha fallback checks, and add documented parameters and return semantics.
@JohnXu22786

Copy link
Copy Markdown
Contributor Author

Follow-up is pushed at c9c53c56. Fast PNG is now an explicit, default-off per-connection option for RDP/VNC; the legacy API and non-RGB24 fallback remain available. The PNG writer reports socket failures, with regression coverage for both writer paths.

Validation: full Autotools make check passed (85 libguac, 15 common, 5 terminal, 11 RDP). The 85-test libguac suite passed under ASan/UBSan with leak detection disabled; the isolated socket-failure check passed with LeakSanitizer enabled. A loopback VNC session emitted valid PNGs with fast-png on and off. On a four-color 640×480 screen, mean PNG output was 524 bytes with the default encoder and 1,248 bytes with fast-png across three sessions per mode. This confirms the expected size trade-off for low-color content; representative remote workload benchmarking remains outstanding.

PR remains open and awaits review of the latest changes.

Propagate PNG transport failures so incomplete image streams cannot be marked successful. Add reproducible local timing and size evidence for the opt-in path.
@JohnXu22786
JohnXu22786 marked this pull request as draft November 2, 2026 16:50
@JohnXu22786
JohnXu22786 marked this pull request as ready for review November 2, 2026 16:54
Keep PR apache#721 aligned with its current base while preserving both PNG and display test wiring.
@JohnXu22786
JohnXu22786 marked this pull request as draft November 2, 2026 22:44
@JohnXu22786
JohnXu22786 marked this pull request as ready for review November 2, 2026 22:46

@necouchman necouchman left a comment

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.

A few updates - in general, please make sure documentation is complete and follows established style throughout the code, even in the test classes.

Comment thread src/libguac/guacamole/client.h Resolved
Comment thread src/libguac/guacamole/user.h Resolved
Comment thread src/libguac/encode-png.c Resolved
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