Skip to content

Conversation

@brougkr
Copy link
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 <[email protected]>
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