diff --git a/fs/etc/xpra/conf.d/10_network.conf.in b/fs/etc/xpra/conf.d/10_network.conf.in index 41e49064c1..3c85b4e6ea 100644 --- a/fs/etc/xpra/conf.d/10_network.conf.in +++ b/fs/etc/xpra/conf.d/10_network.conf.in @@ -36,8 +36,7 @@ lock = auto # Compressors: #compressors = all #compressors = none -#compressors = zlib -compressors = none, lz4, zlib, brotli +compressors = none, lz4, brotli # Default compression (0 to 9): compression_level = 1 diff --git a/fs/share/man/man1/xpra.1 b/fs/share/man/man1/xpra.1 index 78c905793e..a12bd4a160 100644 --- a/fs/share/man/man1/xpra.1 +++ b/fs/share/man/man1/xpra.1 @@ -1311,9 +1311,6 @@ over the network. With the \fBlz4\fP and \fBlzo\fP compressors, there are only two possible values: 0 (meaning no compression) and 1 (compression enabled). -The \fBzlib\fP compressor supports values between 0 -(meaning no compression) and 9, inclusive. It should only be used -when \fBlz4\fP and \fBlzo\fP are not available. This compression is not used on pixel data (except when using the \fBrgb\fP encoding). diff --git a/tests/unittests/unit/net/compression_test.py b/tests/unittests/unit/net/compression_test.py index 9370f34229..59816e7f20 100755 --- a/tests/unittests/unit/net/compression_test.py +++ b/tests/unittests/unit/net/compression_test.py @@ -13,7 +13,7 @@ class TestCompression(unittest.TestCase): def test_main(self): compression.init_all() - assert compression.use("zlib") + assert compression.use("lz4") assert compression.get_compression_caps() assert compression.get_enabled_compressors() for x in compression.get_enabled_compressors(): @@ -57,7 +57,7 @@ def test_compressed_wrapper(self): r = compression.compressed_wrapper("test", b"a"*(compression.MIN_COMPRESS_SIZE+1)) if not r.datatype.startswith("raw"): raise Exception(f"should not be able to use the wrapper without enabling a compressor, but got {r!r}") - for x in ("lz4", "brotli", "zlib", "none"): + for x in ("lz4", "brotli", "none"): if not compression.use(x): continue kwargs = {x : True} diff --git a/tests/unittests/unit/net/protocol_test.py b/tests/unittests/unit/net/protocol_test.py index e5d760e009..a1eb02da79 100755 --- a/tests/unittests/unit/net/protocol_test.py +++ b/tests/unittests/unit/net/protocol_test.py @@ -159,7 +159,7 @@ def check_failed(): def test_encoders_and_compressors(self): for encoder in ("rencodeplus", ): - for compressor in ("lz4", "zlib"): + for compressor in ("lz4", ): p = self.make_memory_protocol() p.enable_encoder(encoder) p.enable_compressor(compressor) diff --git a/tests/xpra/codecs/benchmark.py b/tests/xpra/codecs/benchmark.py index 7c30b0026e..4a3fde322c 100755 --- a/tests/xpra/codecs/benchmark.py +++ b/tests/xpra/codecs/benchmark.py @@ -58,7 +58,6 @@ def main(argv): "quality" : quality, "speed" : speed, "rgb_formats" : ("BGRX", "BGRA", "RGBA", "RGBX", "RGB", "BGR"), - "zlib" : True, "lz4" : True, "alpha" : True, } diff --git a/xpra/audio/src.py b/xpra/audio/src.py index 4f9c8ef822..aded6e9378 100755 --- a/xpra/audio/src.py +++ b/xpra/audio/src.py @@ -266,7 +266,6 @@ def on_new_sample(self, _bus) -> int: def _emit_buffer(self, data, metadata) -> int: if self.stream_compressor and data: cdata = compressed_wrapper("audio", data, level=9, can_inline=True, - zlib=False, lz4=self.stream_compressor=="lz4") if len(cdata) compression.C #brotli is not enabled by default as a generic compressor #but callers may choose to enable it via kwargs: for algo, defval in { - "zlib" : True, "lz4" : True, "brotli" : False, }.items(): @@ -1117,7 +1116,7 @@ def parse_server_capabilities(self, c : typedict) -> bool: log.info(f"server capabilities rejected by {bc}") return False self.server_client_shutdown = c.boolget("client-shutdown", True) - self.server_compressors = c.strtupleget("compressors", ("zlib",)) + self.server_compressors = c.strtupleget("compressors", ) return True def parse_network_capabilities(self, caps : typedict) -> bool: diff --git a/xpra/client/base/stub_client_mixin.py b/xpra/client/base/stub_client_mixin.py index e9cd062088..18e5ba5b8f 100644 --- a/xpra/client/base/stub_client_mixin.py +++ b/xpra/client/base/stub_client_mixin.py @@ -94,7 +94,7 @@ def compressed_wrapper(self, datatype, data, level=5, **kwargs) -> Compressed: """ Dummy utility method for compressing data. Actual client implementations will provide compression - based on the client and server capabilities (lz4, zlib). + based on the client and server capabilities (ie: lz4, brotli). subclasses should override this method. """ assert level>=0 diff --git a/xpra/net/compression.py b/xpra/net/compression.py index 8d65539ef4..17e91dca02 100644 --- a/xpra/net/compression.py +++ b/xpra/net/compression.py @@ -12,8 +12,10 @@ from xpra.common import MIN_COMPRESS_SIZE, MAX_DECOMPRESSED_SIZE -# all the compressors we know about, in the best compatibility order: +# all the compressors we know about: ALL_COMPRESSORS : Tuple[str, ...] = ("lz4", "zlib", "brotli", "none") +# the compressors we may want to use, in the best compatibility order: +TRY_COMPRESSORS : Tuple[str, ...] = ("lz4", "brotli", "none") # order for performance: PERFORMANCE_ORDER : Tuple[str, ...] = ("none", "lz4", "zlib", "brotli") # require compression (disallow 'none'): @@ -55,22 +57,6 @@ def brotli_compress_shim(packet, level): return level | BROTLI_FLAG, brotli_compress(packet, quality=level) return Compression("brotli", brotli_version, brotli_compress_shim, brotli_decompress) -def init_zlib() -> Compression: - #pylint: disable=import-outside-toplevel - import zlib - from xpra.net.protocol.header import ZLIB_FLAG - def zlib_compress(packet, level): - level = min(9, max(1, level)) - if not isinstance(packet, (bytes, bytearray, memoryview)): - packet = bytes(str(packet), 'UTF-8') - return level + ZLIB_FLAG, zlib.compress(packet, level) - def zlib_decompress(data): - d = zlib.decompressobj() - v = d.decompress(data, MAX_DECOMPRESSED_SIZE) - assert not d.unconsumed_tail, "not all data was decompressed" - return v - return Compression("zlib", zlib.__version__, zlib_compress, zlib_decompress) # type: ignore[attr-defined] - def init_none() -> Compression: def nocompress(packet, _level): if not isinstance(packet, bytes): @@ -101,7 +87,7 @@ def init_compressors(*names) -> None: logger(f"no {x}", exc_info=True) def init_all() -> None: - init_compressors(*(list(ALL_COMPRESSORS)+["none"])) + init_compressors(*(list(TRY_COMPRESSORS)+["none"])) def use(compressor) -> bool: @@ -110,7 +96,7 @@ def use(compressor) -> bool: def get_compression_caps(full_info : int=1) -> Dict[str,Any]: caps : Dict[str,Any] = {} - for x in ALL_COMPRESSORS: + for x in TRY_COMPRESSORS: c = COMPRESSION.get(x) if c is None: continue @@ -120,7 +106,7 @@ def get_compression_caps(full_info : int=1) -> Dict[str,Any]: ccaps[""] = True return caps -def get_enabled_compressors(order=ALL_COMPRESSORS) -> Tuple[str,...]: +def get_enabled_compressors(order=TRY_COMPRESSORS) -> Tuple[str,...]: return tuple(x for x in order if x in COMPRESSION) def get_compressor(name) -> Callable: diff --git a/xpra/net/protocol/socket_handler.py b/xpra/net/protocol/socket_handler.py index f0dc918435..3c1005b472 100644 --- a/xpra/net/protocol/socket_handler.py +++ b/xpra/net/protocol/socket_handler.py @@ -510,7 +510,7 @@ def enable_compressor_from_caps(self, caps:typedict) -> None: opts = compression.get_enabled_compressors(order=compression.PERFORMANCE_ORDER) compressors = caps.strtupleget("compressors") log(f"enable_compressor_from_caps(..) options={opts}, compressors from caps={compressors}") - for c in opts: #ie: [zlib, lz4] + for c in opts: #ie: ["lz4", "none"] if c=="none": continue if c in compressors or caps.boolget(c): @@ -538,7 +538,7 @@ def encode(self, packet_in : PacketType) -> List[NetPacketType]: ie: ["blah", [large binary data], "hello", 200] may get converted to: [ - (1, compression_level, [large binary data now zlib compressed]), + (1, compression_level, [large binary data now lz4 compressed]), (0, 0, rencoded(["blah", '', "hello", 200])) ] """ diff --git a/xpra/server/proxy/proxy_instance.py b/xpra/server/proxy/proxy_instance.py index b7462df922..f855e6fece 100644 --- a/xpra/server/proxy/proxy_instance.py +++ b/xpra/server/proxy/proxy_instance.py @@ -252,7 +252,6 @@ def number(k, v): OPTION_WHITELIST : Dict[str,Callable] = { "compression_level" : number, "lz4" : parse_bool, - "zlib" : parse_bool, "rencodeplus" : parse_bool, "yaml" : parse_bool, } @@ -393,7 +392,7 @@ def _packet_recompress(self, packet : PacketType, index:int, name:str) -> Packet if len(data) None: self.default_encoding_options = typedict() self.auto_refresh_delay : int = 0 - self.zlib = True self.lz4 = use("lz4") #for managing the recalculate_delays work: @@ -249,11 +248,9 @@ def parse_batch_int(value, varname): return v #general features: - self.zlib = c.boolget("zlib", True) self.lz4 = c.boolget("lz4", False) and use("lz4") self.brotli = c.boolget("brotli", False) and use("brotli") - log("compressors: zlib=%s, lz4=%s, brotli=%s", - self.zlib, self.lz4, self.brotli) + log("compressors: lz4=%s, brotli=%s", self.lz4, self.brotli) delay = batch_config.START_DELAY dbc = self.default_batch_config @@ -292,15 +289,15 @@ def parse_encoding_caps(self, c:typedict) -> None: #encoding options (filter): #1: these properties are special cased here because we #defined their name before the "encoding." prefix convention, - #or because we want to pass default values (zlib/lz4): + #or because we want to pass default values (ie: lz4): for k,ek in {"initial_quality" : "initial_quality", "quality" : "quality", }.items(): if k in c: self.encoding_options[ek] = c.intget(k) - for k,ek in {"zlib" : "rgb_zlib", - "lz4" : "rgb_lz4", - }.items(): + for k,ek in { + "lz4" : "rgb_lz4", + }.items(): if k in c: self.encoding_options[ek] = c.boolget(k) #2: standardized encoding options: @@ -312,7 +309,7 @@ def parse_encoding_caps(self, c:typedict) -> None: elif k.startswith("encoding."): stripped_k = k[len("encoding."):] if stripped_k in ("transparency", - "rgb_zlib", "rgb_lz4", + "rgb_lz4", ): v = c.boolget(k) elif stripped_k in ("initial_quality", "initial_speed",