Skip to content

Network cleanup: consolidate input/output streams#10664

Open
MostCromulent wants to merge 1 commit into
Card-Forge:masterfrom
MostCromulent:consolidate-trackable-codec
Open

Network cleanup: consolidate input/output streams#10664
MostCromulent wants to merge 1 commit into
Card-Forge:masterfrom
MostCromulent:consolidate-trackable-codec

Conversation

@MostCromulent
Copy link
Copy Markdown
Contributor

@MostCromulent MostCromulent commented May 12, 2026

Summary

Comment on #10662 asked whether TrackableSerializer.ReplacingOutputStream/ResolvingInputStream were still needed once the outer-pipeline CObjectOutputStream/CObjectInputStream had grown the Tracker/consumerId plumbing.

They weren't — the inner pair only served three call sites (wrapEvents, unwrapEvents, measureSize), all of which can be expressed in terms of the outer codec. The inner pair wrote full ObjectStreamClass blocks, carrying serialVersionUID on the wire — which is what the Android records workaround in ResolvingInputStream.readClassDescriptor had to compensate for (JVM keeps records at 0L, d8 desugars records with a computed UID). CObjectOutputStream writes thin descriptors — a one-byte tag plus the UTF class name — so no UID travels on the wire and the disagreement never surfaces.

Routing the three inner call sites through CObjectOutputStream/CObjectInputStream makes the workaround unreachable, and it's deleted with the classes.

Implementation

  • CObjectOutputStream gains an eventMode parameter so it can serve as both the outer-pipeline encoder (IdRef substitution) and the event-wrap encoder (EventCardRef substitution). The single outer caller in CompatibleObjectEncoder passes false.
  • wrapEvents switches to new CObjectOutputStream(baos, true, tracker, -1, true). unwrapEvents switches to new CObjectInputStream(bais, INNER_CLASS_RESOLVER, tracker). measureSize switches and gains exception-safe try-with-resources.
  • INNER_CLASS_RESOLVER is a static ClassResolvers.cacheDisabled(null) on TrackableSerializer, matching what the outer Netty pipeline uses in FServerManager/FGameClient.
  • ReplacingOutputStream and ResolvingInputStream are deleted, taking the UID-mismatch fallback with them.

Testing completed

  • Smoke-tested cross-platform netplay with an Android emulator, events deserialize cleanly on both sides.

🤖 Generated with Claude Code

Drops ReplacingOutputStream/ResolvingInputStream — wrapEvents,
unwrapEvents, measureSize now go through CObjectOutputStream and
CObjectInputStream. Thin descriptors don't carry serialVersionUID,
so the Android record UID fallback is gone with them.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@MostCromulent MostCromulent requested a review from tool4ever May 12, 2026 22:36
@MostCromulent MostCromulent changed the title Network cleanup: consolidate codecs Network cleanup: consolidate input/output streams May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant