Skip to content

Restore the non-direct frame fallback, cipher into a direct buffer - #877

Merged
electronicboy merged 1 commit into
masterfrom
fix/nativezlib-packet-decompression
Sep 5, 2026
Merged

Restore the non-direct frame fallback, cipher into a direct buffer#877
electronicboy merged 1 commit into
masterfrom
fix/nativezlib-packet-decompression

Conversation

@electronicboy

Copy link
Copy Markdown
Member

Defaulting the native cipher off in 5a1ca80 made JavaCipher the default, and it emitted a heap ByteBuf. That became the cumulation for Varint21FrameDecoder, whose Waterfall patch had dropped upstream's hasMemoryAddress() check, so frames were sliced straight out of a heap buffer and handed to the still-native zlib:

java.lang.UnsupportedOperationException
at io.netty.buffer.PooledHeapByteBuf.memoryAddress
at net.md_5.bungee.jni.zlib.NativeZlib.process
at net.md_5.bungee.compress.PacketDecompressor.decode

Every online-mode player hit this on join.

0042 drops the hunk that removed upstream's fallback, restoring the invariant the native zlib depends on. 0068 then fixes the source: JavaCipher ciphers into a direct buffer, so frames stay zero-copy slices and the fallback is not on the hot path. 0067 covers both the decoder's fallback and the full cipher chain.

Defaulting the native cipher off in 5a1ca80 made JavaCipher the default, and it
emitted a heap ByteBuf. That became the cumulation for Varint21FrameDecoder, whose
Waterfall patch had dropped upstream's hasMemoryAddress() check, so frames were
sliced straight out of a heap buffer and handed to the still-native zlib:

  java.lang.UnsupportedOperationException
    at io.netty.buffer.PooledHeapByteBuf.memoryAddress
    at net.md_5.bungee.jni.zlib.NativeZlib.process
    at net.md_5.bungee.compress.PacketDecompressor.decode

Every online-mode player hit this on join.

0042 drops the hunk that removed upstream's fallback, restoring the invariant the
native zlib depends on. 0068 then fixes the source: JavaCipher ciphers into a direct
buffer, so frames stay zero-copy slices and the fallback is not on the hot path.
0067 covers both the decoder's fallback and the full cipher chain.
@electronicboy
electronicboy merged commit 7eeb258 into master Sep 5, 2026
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.

1 participant