ADR-283: NTP Time Syncronization

More details about this document
Latest published version:
https://adr.decentraland.org/adr/ADR-283
Authors:
gonpombo8
Feedback:
GitHub decentraland/adr (pull requests, new issue, open issues)
Edit this documentation:
GitHub View commits View commits on githistory.xyz

ADR-283: Time Synchronization

Abstract

This document describes a time synchronization mechanism for the Decentraland Unity client that provides a unified source of synchronized time across all clients. By implementing Network Time Protocol (NTP) synchronization and introducing the PBSyncedClock component, this ADR establishes a foundation for any time-dependent feature in Decentraland that requires coordination across multiple clients. The initial implementation enhances PBTween with synchronized timestamps, but the system is designed to support animations, video players, sounds, and other time-sensitive features.

Context, Reach & Prioritization

The Decentraland platform lacks a unified time synchronization mechanism, which affects multiple systems that rely on coordinated timing across clients:

Currently, all these systems rely on local client time, which leads to:

This limitation affects:

The prioritization of this feature is driven by:

  1. Foundational requirement: Time synchronization is a prerequisite for many advanced features
  2. Multiple use cases: One implementation benefits tweens, animations, video, and audio
  3. Community demand: Creators consistently request better synchronization capabilities

Solution Space Exploration

Option 1: Server-Sent Timestamps (Rejected)

Relying solely on timestamps sent by the realm server was considered but rejected because:

Option 2: Local Time Only (Current State - Rejected)

Continuing with the current system of local client time was rejected as it prevents any form of synchronized experience.

Option 3: NTP-Based Synchronization (Selected)

Implement client-side NTP synchronization with reliable time servers. This approach:

Specification

Protocol Changes

New Component: PBSyncedClock

A new Protocol Buffers component will be added at proto/decentraland/sdk/components/synced_clock.proto:

syntax = "proto3";

package decentraland.sdk.components;

import "decentraland/sdk/components/common/id.proto";
option (common.ecs_component_id) = 1099;

// PBSyncedClock provides synchronized time information based on NTP server data
// This component can be used to maintain consistent time across all clients
message PBSyncedClock {
  // The current synchronized time (in milliseconds since epoch)
  uint64 synced_timestamp = 1;

  // The synchronization status
  SyncStatus status = 7;
}

// Status of time synchronization
enum SyncStatus {
  // The component is not yet synchronized with the NTP server
  SS_UNINITIALIZED = 0;

  // The component is currently attempting to synchronize with the NTP server
  SS_SYNCHRONIZING = 1;

  // The component is successfully synchronized with the NTP server
  SS_SYNCHRONIZED = 2;

  // The component failed to synchronize with the NTP server
  SS_ERROR = 3;
}

Enhanced PBTween Component

The existing PBTween component will be modified to include:

message PBTween {
  // ... existing fields ...
  optional uint64 start_synced_timestamp = 9; // timestamp (in milliseconds) when the tween started, allows synchronization across clients
}

Implementation Details

Phase 1: NTP Time Synchronization

  1. Time Synchronization Client

  2. Synchronization Process

Phase 2: SyncedClock System

  1. TimeComponentSystem

  2. Error Handling

Phase 3: System Integration

  1. Tween System (Initial Implementation)

  2. Future Integrations

Use Cases

Immediate (Tweens)

  1. Moving Platforms: Consistent position across all players
  2. Elevators: Synchronized arrival/departure times
  3. Rotating Objects: Identical rotation state for all users
  4. Doors and Gates: Open/close at the same moment

Future Possibilities

  1. Synchronized Animations: Dance performances, cutscenes, visual effects
  2. Shared Video Experiences: Watch parties, presentations, tutorials
  3. Musical Experiences: Synchronized background music, rhythm games
  4. Timed Events: Countdowns, scheduled activities, time-based puzzles

Backward Compatibility

Consequences

Positive

Negative

Security Considerations

Performance Considerations

Open Questions

  1. Should Decentraland host its own NTP servers or rely on public infrastructure?

RFC 2119 and RFC 8174

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 and RFC 8174.

Copyright

Copyright and related rights waived via CC0-1.0.

License

Copyright and related rights waived via CC0-1.0. DRAFT Final