Skip to content

fix(unreal): Replace FTickableGameObject with FTSTicker and add compressed message buffering#4006

Closed
brougkr wants to merge 1 commit intoclockworklabs:masterfrom
brougkr:fix/unreal-sdk-message-buffering
Closed

fix(unreal): Replace FTickableGameObject with FTSTicker and add compressed message buffering#4006
brougkr wants to merge 1 commit intoclockworklabs:masterfrom
brougkr:fix/unreal-sdk-message-buffering

Conversation

@brougkr
Copy link
Copy Markdown
Contributor

@brougkr brougkr commented Jan 12, 2026

Summary

This PR fixes two issues in the Unreal SDK:

  1. FTickableGameObject initialization order bug - Replaced with FTSTicker for reliable tick registration
  2. Fragmented compressed WebSocket message handling - Added buffering for messages that span multiple frames

Problem

Issue 1: FTickableGameObject

FTickableGameObject registers itself in its constructor BEFORE UDbConnectionBase's constructor body runs. Even with ETickableTickType::Never, UE's GENERATED_BODY() macro can interfere with base class initialization order, causing the default constructor to be called instead.

Issue 2: Fragmented Messages

Large compressed messages from SpacetimeDB can arrive fragmented across multiple WebSocket frames. The current implementation assumes complete messages arrive in single frames, causing decompression failures.

Solution

FTSTicker Replacement

  • Removed FTickableGameObject inheritance
  • Added FTSTicker::FDelegateHandle for manual tick registration
  • Added destructor to clean up ticker registration
  • Added OnTickerTick() method

Compressed Message Buffering

  • Added CompressedBufferMutex to protect accumulation buffer
  • Added IncompleteCompressedBuffer for fragment accumulation
  • Added BufferedCompressionType to track compression across fragments
  • Enhanced gzip validation to detect incomplete data and trigger buffering

Changes

  • Public/Connection/DbConnectionBase.h - Class declaration changes, new members
  • Private/Connection/DbConnectionBase.cpp - Implementation of buffering and ticker system

Testing

Tested in production Unreal 5.7 project with SpacetimeDB backend. Fixes previously observed:

  • Random tick registration failures on connection
  • Decompression errors on large subscription payloads

…essed message buffering

- Replaced FTickableGameObject with FTSTicker to fix initialization order issues
- Added CompressedBufferMutex and buffering for fragmented WebSocket messages
- Enhanced gzip validation to detect incomplete data

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@JasonAtClockwork
Copy link
Copy Markdown
Contributor

Thanks again @brougkr!

Just FYI I've finally come back to this and split out to a new PR with just the changes for the tick as we had the other fix #4002 to handle the fragmentation a little deeper in the SDK. I'm closing this PR and will lead with #4835 to get this merged soon.

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.

3 participants