Menu

Reading a 150 MB playlist on a 4 GB TV box without running out of memory
📰

Reading a 150 MB playlist on a 4 GB TV box without running out of memory

DEV Community: reactnative·Usama Muhammad·12 days ago
#re21VvVa
#devtoreactnative#devto#dev#extinf#json
Reading 0:00
15s threshold

I build NewTV Player, a media player for people's own playlists (an M3U link or an Xtream login from their provider). It runs on phones, Android TV boxes, Fire TV and Windows, and it is written in React Native with Expo and SQLite.

The hardest bug I have fixed in it had nothing to do with video. It was a JSON file.

The bug: an empty playlist on a 4 GB box

A user on an Android TV box with 4 GB of memory added their subscription. The progress bar moved, the app worked for a while, and then the playlist was simply empty. No crash report, no error on screen.

The reason was size. Xtream panels answer three calls for a catalogue: live channels, films and series. Each one is a single JSON array. For real subscriptions we measured 72 MB in one list and 156 MB across the three .

The first version did what most code does:

const res = await fetch ( url ); const items = JSON . parse ( await res .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.