dash.js
Open Source Media Player
Seamless and reliable DASH streaming on any browser-based device
View onGitHub
5495
1729
448k
Sponsors
Trusted by the industry leaders
Latest updates from GitHub
Subtitle rendering intermittently stopping during playback on Smart TVsHello ,
We are facing an occasional issue where subtitles stop displaying while video playback is still running normally. The behavior appears to be random and so far has been difficult to reproduce.
What we know so far:
- The issue has been reported on Smart TV devices
- We currently don’t have any logs that capture the moment when it happens
- The reports are based mainly on end-user feedback
- Subtitles only reappear after a user interaction, such as seeking in the content
We wanted to check whether this is something you have already encountered, and if you might have any ideas or hypotheses about what could cause this kind of behavior.
Any insight would be greatly appreciated.Opened by testeur-990—11 days ago
Reduce memory allocations in hot paths for Smart TV optimization## Description
Several hot code paths in dash.js use `Object.keys()` patterns that create unnecessary array allocations during playback. On resource-constrained devices like Smart TVs, these allocations contribute to garbage collection pressure, potentially causing playback stutters.
## Affected Areas
| File | Function | Frequency | Issue |
|------|----------|-----------|-------|
| `AbrController.js` | `_onVideoElementResized` | Every video resize | Nested `Object.keys().forEach()` |
| `EventController.js` | `_iterateAndTriggerCallback` | Every 100ms | `Object.keys()` in nested loops |
| `EventController.js` | `_removeOutdatedEventObjects` | Every 100ms | `Object.keys().length === 0` check |
| `HTTPLoader.js` | `_addPathwayCloningParameters` | Every HTTP request | `Object.keys().map()` |
## Proposed Solution
Replace `Object.keys()` patterns with `for..in` loops which iterate directly without creating intermediate arrays.
## Expected Impact
- Reduces ~30-50 array allocations per second during playback
- Lower GC pressure on memory-constrained devices
- More fluid playback on Smart TVs and embedded devices
## Related PR
#4937Opened by PascalThuet—11 days ago
Memory leak: InitCache grows unbounded during multi-period playback## Problem
`InitCache` stores init segments indefinitely without any eviction mechanism:
```javascript
// Current implementation (InitCache.js)
let data = {};
function save(chunk) {
const id = chunk.streamId;
const representationId = chunk.representation.id;
data[id] = data[id] || {};
data[id][representationId] = chunk; // Never removed
}
```
During multi-period content or stream switches:
- Each period/stream adds new entries to the cache
- Old entries are never evicted
- Memory grows proportionally to the number of unique (streamId, representationId) pairs
## Impact
- For long-form content with many periods, cache can grow to hundreds of entries
- Init segments can be 1-10KB each, totaling several MB over time
- No mechanism to clean up when streams end
- Critical for Smart TV devices with limited memory
## Reproduction
1. Play multi-period DASH content (e.g., ad insertion with many ad pods)
2. Monitor `InitCache.data` object growth
3. Observe entries accumulate without cleanup
## Proposed Solution
Implement a bounded LRU (Least Recently Used) cache with:
- Maximum entry limit (e.g., 50 entries)
- Automatic eviction of oldest entries when limit is exceeded
- Optional `removeStream(streamId)` method for explicit cleanup
## Environment
- dash.js version: 5.x
- Affects: All platforms, critical on Smart TVOpened by PascalThuet—13 days ago






