decentraland / decentraland/unity-explorer
Tech Debt: Harden media buffering loop against mid-wait error/close in UUAV backend
- Dominant language
- C#
- Stars
- 23
- Forks
- 17
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 101
Description
## Context
The UUAV backend returns a buffered range once media is ready — the compat layer implements this gate deliberately (see comments at `UuavBackend.cs:78` and `AVProCompat/UUAVBackend.cs:73`).
## Problem
The **hang-forever case** is triggered when media errors or closes mid-wait. This hangs identically on AVPro today since the problematic line predates the UUAV migration PR — it is **not a regression**, but a pre-existing gap now surfaced.
## Proposed Fix
The buffering loop should be hardened in one (or both) of the following ways:
1. **Break on error state:** Exit the loop when `GetLastError() != ErrorCode.None`. UUAV maps the `Error` state to `LoadFailed`, so this would allow the caller to handle the failure gracefully instead of hanging indefinitely.
2. **Accept a cancellation token:** Pass a `CancellationToken` into the loop so callers can time out or cancel the wait externally.
## Why a separate ticket
This is explicitly **not a regression** from the AVPro → UUAV migration. The hang existed before the migration on AVPro. Fixing it is a hardening improvement and is best tracked independently.
## Files to investigate
- `UuavBackend.cs` (around line 78)
- `AVProCompat/UUAVBackend.cs` (around line 73)
---
_Requested by Nikita Khalov via Slack_
Contributor guide
Research direction
Read the buffering gate and nearby comments in UuavBackend.cs around line 78, then compare the corresponding loop in AVProCompat/UUAVBackend.cs around line 73. Trace how error and close states are reported to callers; done means the wait cannot hang indefinitely when media fails or closes, with the chosen cancellation or error-handling behavior covered by the relevant tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- audio-video-rtc, backend
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100