Skip to content

tvOS: enabling embedded mov_text subtitles on a specific MP4/MOV-style file causes runaway memory growth and eventual OOM / jetsam #104

Closed

Description

@cwikstrom22

What happened?

Summary

On tvOS, Aether playback is stable for the affected file when subtitles are off. If any embedded mov_text subtitle track is enabled, memory grows steadily until the app is terminated for exceeding the process memory limit.

I also tested with my apps subtitle UI path disabled:
• subtitle overlay rendering disabled
• subtitle cue observation/subscription disabled

The memory growth still occurs, which suggests the leak is inside AetherEngine’s subtitle handling rather than in the app UI layer.

Environment

• Platform: tvOS
• Device: Apple TV 4K (AppleTV14,1)
• OS: tvOS 26.5
• App process limit observed in crash: about 2098 MB
• Engine: AetherEngine
• Subtitle format on failing file: embedded mov_text

What works

• Different format subtitle-enabled file: stable memory
• Problem file with subtitles off: stable memory

What fails

• Problem file with any embedded subtitle track enabled:
• English, French, Swedish all reproduced the issue
• memory rises steadily until OOM / jetsam

Key evidence

Crash reason:
• EXC_RESOURCE (RESOURCE_TYPE_MEMORY: high watermark memory limit exceeded)
• limit about 2098 MB

Failing file behavior:
• startup memory around footprintMB=165
• enabling subtitles causes cue count to rise steadily
• memory rises with it, for example:
• playback-517s footprintMB=280
• playback-547s footprintMB=566
• playback-577s footprintMB=700
• later runs exceeded 900+ MB and eventually crashed

Turning subtitles off on the same file:
• activePrimarySubtitles=nil
• cue count returns to 0
• memory drops back near baseline, for example:
• footprintMB=156

Different file with different format subtitles enabled:
• cue counts increase normally
• memory remains stable around 182–189 MB footprint

Subtitle metadata from failing file

All embedded subtitle tracks reported as mov_text, for example:
• id=2 lang=eng codec=mov_text
• id=3 lang=eng codec=mov_text
• id=4 lang=spa codec=mov_text
• id=5 lang=spa codec=mov_text
• id=6 lang=fra codec=mov_text
• id=7 lang=fra codec=mov_text
• id=8 lang=por codec=mov_text
• id=9 lang=por codec=mov_text
• id=10 lang=dan codec=mov_text
• id=11 lang=deu codec=mov_text
• id=12 lang=fin codec=mov_text
• id=13 lang=ita codec=mov_text
• id=14 lang=jpn codec=mov_text
• id=15 lang=nld codec=mov_text
• id=16 lang=pol codec=mov_text
• id=17 lang=swe codec=mov_text

Isolation tests already performed

  1. Subtitles off on failing file
    • memory stable

  2. Subtitles on, subtitle overlay rendering disabled in app
    • memory still grows

  3. Subtitles on, subtitle cue observation disabled in app
    • memory still grows

  4. Different subtitle-enabled file
    • memory stable

These tests strongly suggest the issue is below the UI layer, likely in subtitle decode/demux/storage for this file’s mov_text streams.

Suspected area

Likely in Aether/FFmpeg subtitle handling for mov_text, possibly:
• subtitle packet lifecycle / cleanup
• subtitle sample retention
• subtitle decoder state / side-data retention
• file-specific mov_text stream characteristics

Why this seems file-specific

Another subtitle-enabled file was tested under the same build and remained stable, so this does not appear to be “all subtitles leak.” It appears tied to this file or its embedded mov_text subtitle streams.

Steps to reproduce

Repro steps

  1. Play the affected file on tvOS with subtitles off
  2. Observe stable memory
  3. Enable any embedded subtitle track
  4. Observe memory begin climbing steadily
  5. Continue playback until tvOS kills the app for memory pressure

AetherEngine version or commit SHA

4.9.1

Host app

Custom / my own integration

Platform

tvOS

OS version

tvOS 26.2

Device / chip

Apple TV 4K (AppleTV14,1)

Playback path

Not sure / not a playback bug

Source media (for playback bugs)

Video: 1080p H264 SDR
Audio: Dolby Digital 5.1

Error codes / log lines

EXC_RESOURCE (RESOURCE_TYPE_MEMORY: high watermark memory limit exceeded)

Anything else

I a quite the novice at coding so I hope the information provided is useful.

Activity

  1. added
    bug
    on Jul 5, 2026
  2. superuser404notfound commented on Jul 5, 2026

    @superuser404notfound
    Owner

    Thanks again for the very careful isolation work. It pointed straight at the right layer.

    I found the cause, and it is not the cue count (that is a symptom). AetherEngine opens a second, separate demuxer to harvest the subtitle cues for the selected track. That side reader was missing one guard that the main playback demuxer already has: it never told the demuxer to discard the streams it does not use. So while a subtitle track was selected, it was pulling your file's entire video and audio through a second streaming connection, sample by sample, just to reach the sparse text subtitles. The more of the file it worked through, the more memory it held, which is why it climbed with playback position and dropped back to baseline the moment you turned subtitles off (that tears the side reader down). Your file has 16 subtitle tracks, which made this path especially heavy, and explains why a different, simpler file stayed flat.

    The fix makes that side reader discard video and audio, so it only reads the tiny subtitle samples. It also makes subtitles appear faster as a side effect.

    It is on main now: AetherEngine d928083. If you can point your build at that commit and retest the same file with subtitles on, it should stay flat.

    If it still grows after that, one more thing would let me localize any remaining leak precisely: the engine logs a full memory breakdown every 30 seconds. In your logs, filter for lines starting with [AetherEngine] memprobe and paste 3 or 4 (early, mid, and near the top). Those split memory into buckets (heap, decoded frames, segment cache, live packets, and so on), so whichever one climbs tells me exactly where to look next. But please try the fix first.

  3. cwikstrom22 commented on Jul 5, 2026

    @cwikstrom22
    Author

    Thank you so much for such a quick response :)

    I updated to the latest package (4.11.0) and tested again. I am seeing the same results as before. Here are the memprobe logs you requested. They start with subtitles turned off and end when the app crashes due to the memory overload. when the app crashed the memory usage was at 2.05gb.

    [AetherEngine] memprobe t=30s rss=200MB vmInt=107MB vmExt=76MB vmCmp=31MB vmIOS=0MB physFP=164MB mallocBlocks=275308 mallocMB=124 avioFetchedMB=106 cacheCount=19 cacheMB=77 packetsWritten=1824 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=77 muxCuts=19 srvConns=1 srvBytesMB=25 srvSfMB=25 pktAlive=3 pktTotal=37914 subCues=0 audioTracks=1 subTracks=16 subActive=false avBufAhead=6.6s avBufBehind=29.3s frameAhead=0.00s prodShift=-0.08s hostShift=-0.08s seams=1
    [AetherEngine] memprobe t=60s rss=197MB vmInt=104MB vmExt=76MB vmCmp=30MB vmIOS=0MB physFP=161MB mallocBlocks=274927 mallocMB=121 avioFetchedMB=142 cacheCount=26 cacheMB=113 packetsWritten=2496 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=113 muxCuts=26 srvConns=1 srvBytesMB=62 srvSfMB=62 pktAlive=3 pktTotal=39461 subCues=0 audioTracks=1 subTracks=16 subActive=false avBufAhead=4.5s avBufBehind=33.4s frameAhead=0.00s prodShift=-0.08s hostShift=-0.08s seams=1
    [AetherEngine] memprobe t=90s rss=201MB vmInt=108MB vmExt=76MB vmCmp=30MB vmIOS=0MB physFP=164MB mallocBlocks=274774 mallocMB=125 avioFetchedMB=179 cacheCount=34 cacheMB=150 packetsWritten=3264 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=150 muxCuts=34 srvConns=1 srvBytesMB=103 srvSfMB=103 pktAlive=3 pktTotal=41229 subCues=0 audioTracks=1 subTracks=16 subActive=false avBufAhead=6.5s avBufBehind=31.5s frameAhead=0.00s prodShift=-0.08s hostShift=-0.08s seams=1
    [AetherEngine] memprobe t=120s rss=199MB vmInt=106MB vmExt=76MB vmCmp=30MB vmIOS=0MB physFP=162MB mallocBlocks=274797 mallocMB=124 avioFetchedMB=212 cacheCount=41 cacheMB=184 packetsWritten=3936 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=184 muxCuts=41 srvConns=1 srvBytesMB=138 srvSfMB=138 pktAlive=3 pktTotal=42776 subCues=0 audioTracks=1 subTracks=16 subActive=false avBufAhead=7.9s avBufBehind=30.0s frameAhead=0.00s prodShift=-0.08s hostShift=-0.08s seams=1
    [AetherEngine] memprobe t=150s rss=383MB vmInt=285MB vmExt=76MB vmCmp=30MB vmIOS=0MB physFP=340MB mallocBlocks=285003 mallocMB=341 avioFetchedMB=248 cacheCount=48 cacheMB=219 packetsWritten=4608 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=219 muxCuts=48 srvConns=1 srvBytesMB=171 srvSfMB=171 pktAlive=3 pktTotal=51938 subCues=43 audioTracks=1 subTracks=16 subActive=true avBufAhead=5.8s avBufBehind=32.1s frameAhead=0.00s prodShift=-0.08s hostShift=-0.08s seams=1
    [AetherEngine] memprobe t=180s rss=553MB vmInt=459MB vmExt=76MB vmCmp=29MB vmIOS=0MB physFP=511MB mallocBlocks=285494 mallocMB=480 avioFetchedMB=283 cacheCount=56 cacheMB=254 packetsWritten=5376 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=254 muxCuts=56 srvConns=1 srvBytesMB=209 srvSfMB=209 pktAlive=3 pktTotal=55699 subCues=56 audioTracks=1 subTracks=16 subActive=true avBufAhead=7.7s avBufBehind=30.2s frameAhead=0.00s prodShift=-0.08s hostShift=-0.08s seams=1
    [AetherEngine] memprobe t=210s rss=863MB vmInt=772MB vmExt=76MB vmCmp=29MB vmIOS=0MB physFP=823MB mallocBlocks=286361 mallocMB=933 avioFetchedMB=316 cacheCount=63 cacheMB=287 packetsWritten=6048 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=287 muxCuts=63 srvConns=1 srvBytesMB=243 srvSfMB=243 pktAlive=3 pktTotal=59296 subCues=70 audioTracks=1 subTracks=16 subActive=true avBufAhead=5.7s avBufBehind=32.2s frameAhead=0.00s prodShift=-0.08s hostShift=-0.08s seams=1
    [AetherEngine] memprobe t=240s rss=892MB vmInt=802MB vmExt=76MB vmCmp=29MB vmIOS=0MB physFP=852MB mallocBlocks=286802 mallocMB=934 avioFetchedMB=352 cacheCount=71 cacheMB=324 packetsWritten=6816 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=324 muxCuts=71 srvConns=1 srvBytesMB=280 srvSfMB=280 pktAlive=3 pktTotal=63063 subCues=85 audioTracks=1 subTracks=16 subActive=true avBufAhead=7.6s avBufBehind=30.3s frameAhead=0.00s prodShift=-0.08s hostShift=-0.08s seams=1
    [AetherEngine] memprobe t=270s rss=952MB vmInt=867MB vmExt=75MB vmCmp=105MB vmIOS=0MB physFP=993MB mallocBlocks=285153 mallocMB=1149 avioFetchedMB=389 cacheCount=78 cacheMB=360 packetsWritten=7488 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=360 muxCuts=78 srvConns=1 srvBytesMB=310 srvSfMB=310 pktAlive=3 pktTotal=66447 subCues=95 audioTracks=1 subTracks=16 subActive=true avBufAhead=5.6s avBufBehind=32.4s frameAhead=0.00s prodShift=-0.08s hostShift=-0.08s seams=1
    [AetherEngine] memprobe t=300s rss=932MB vmInt=847MB vmExt=75MB vmCmp=104MB vmIOS=0MB physFP=972MB mallocBlocks=285570 mallocMB=1126 avioFetchedMB=426 cacheCount=86 cacheMB=397 packetsWritten=8256 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=397 muxCuts=86 srvConns=1 srvBytesMB=349 srvSfMB=349 pktAlive=3 pktTotal=69939 subCues=102 audioTracks=1 subTracks=16 subActive=true avBufAhead=7.6s avBufBehind=30.4s frameAhead=0.00s prodShift=-0.08s hostShift=-0.08s seams=1
    [AetherEngine] memprobe t=330s rss=928MB vmInt=843MB vmExt=75MB vmCmp=104MB vmIOS=0MB physFP=968MB mallocBlocks=285968 mallocMB=1117 avioFetchedMB=460 cacheCount=93 cacheMB=432 packetsWritten=8928 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=432 muxCuts=93 srvConns=1 srvBytesMB=382 srvSfMB=382 pktAlive=3 pktTotal=73302 subCues=113 audioTracks=1 subTracks=16 subActive=true avBufAhead=5.5s avBufBehind=32.4s frameAhead=0.00s prodShift=-0.08s hostShift=-0.08s seams=1
    [AetherEngine] memprobe t=360s rss=210MB vmInt=130MB vmExt=75MB vmCmp=125MB vmIOS=0MB physFP=275MB mallocBlocks=285660 mallocMB=1192 avioFetchedMB=503 cacheCount=101 cacheMB=474 packetsWritten=9696 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=474 muxCuts=101 srvConns=1 srvBytesMB=423 srvSfMB=423 pktAlive=3 pktTotal=77040 subCues=125 audioTracks=1 subTracks=16 subActive=true avBufAhead=7.4s avBufBehind=30.5s frameAhead=0.00s prodShift=-0.08s hostShift=-0.08s seams=1

  4. superuser404notfound commented on Jul 5, 2026

    @superuser404notfound
    Owner

    Please test against the newest main, not 4.11.0.

  5. cwikstrom22 commented on Jul 5, 2026

    @cwikstrom22
    Author

    Ugh! My apologies. I switched to the main branch (4171ef4). I performed the same testing as before and It still crashes out with memory maxed at 2.05gb. Below are the logs memprobe logs. The last entry before it crashed shows 153mb of memory used but right after that log hit it spiked to 2.05gb. If there is anything else or any other logs that would help, please let me know and I will do my best to get them for you.

    [AetherEngine] memprobe t=30s rss=283MB vmInt=170MB vmExt=80MB vmCmp=0MB vmIOS=0MB physFP=205MB mallocBlocks=269306 mallocMB=189 avioFetchedMB=101 cacheCount=18 cacheMB=72 packetsWritten=1728 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=72 muxCuts=18 srvConns=1 srvBytesMB=19 srvSfMB=15 pktAlive=3 pktTotal=10094 subCues=27 audioTracks=1 subTracks=16 subActive=true avBufAhead=4.3s avBufBehind=27.6s frameAhead=0.00s prodShift=-0.08s hostShift=-0.08s seams=1

    [AetherEngine] memprobe t=60s rss=281MB vmInt=168MB vmExt=80MB vmCmp=0MB vmIOS=0MB physFP=203MB mallocBlocks=268962 mallocMB=187 avioFetchedMB=142 cacheCount=26 cacheMB=113 packetsWritten=2496 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=113 muxCuts=26 srvConns=1 srvBytesMB=62 srvSfMB=58 pktAlive=3 pktTotal=13833 subCues=39 audioTracks=1 subTracks=16 subActive=true avBufAhead=6.2s avBufBehind=31.7s frameAhead=0.00s prodShift=-0.08s hostShift=-0.08s seams=1

    [AetherEngine] memprobe t=90s rss=290MB vmInt=176MB vmExt=80MB vmCmp=0MB vmIOS=0MB physFP=211MB mallocBlocks=268839 mallocMB=193 avioFetchedMB=176 cacheCount=33 cacheMB=147 packetsWritten=3168 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=147 muxCuts=33 srvConns=1 srvBytesMB=98 srvSfMB=94 pktAlive=3 pktTotal=17380 subCues=52 audioTracks=1 subTracks=16 subActive=true avBufAhead=4.2s avBufBehind=33.7s frameAhead=0.00s prodShift=-0.08s hostShift=-0.08s seams=1

    [AetherEngine] memprobe t=120s rss=528MB vmInt=414MB vmExt=80MB vmCmp=0MB vmIOS=0MB physFP=448MB mallocBlocks=267941 mallocMB=481 avioFetchedMB=212 cacheCount=41 cacheMB=184 packetsWritten=3936 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=184 muxCuts=41 srvConns=1 srvBytesMB=138 srvSfMB=134 pktAlive=3 pktTotal=21012 subCues=61 audioTracks=1 subTracks=16 subActive=true avBufAhead=6.2s avBufBehind=31.8s frameAhead=0.00s prodShift=-0.08s hostShift=-0.08s seams=1

    [AetherEngine] memprobe t=150s rss=639MB vmInt=526MB vmExt=80MB vmCmp=0MB vmIOS=0MB physFP=557MB mallocBlocks=267957 mallocMB=529 avioFetchedMB=248 cacheCount=48 cacheMB=219 packetsWritten=4608 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=219 muxCuts=48 srvConns=1 srvBytesMB=171 srvSfMB=168 pktAlive=3 pktTotal=24506 subCues=71 audioTracks=1 subTracks=16 subActive=true avBufAhead=4.1s avBufBehind=33.8s frameAhead=0.00s prodShift=-0.08s hostShift=-0.08s seams=1

    [AetherEngine] memprobe t=180s rss=961MB vmInt=846MB vmExt=80MB vmCmp=0MB vmIOS=0MB physFP=875MB mallocBlocks=271777 mallocMB=982 avioFetchedMB=283 cacheCount=56 cacheMB=254 packetsWritten=5376 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=254 muxCuts=56 srvConns=1 srvBytesMB=209 srvSfMB=205 pktAlive=3 pktTotal=28249 subCues=83 audioTracks=1 subTracks=16 subActive=true avBufAhead=6.0s avBufBehind=31.9s frameAhead=0.00s prodShift=-0.08s hostShift=-0.08s seams=1

    [AetherEngine] memprobe t=210s rss=1065MB vmInt=980MB vmExt=79MB vmCmp=148MB vmIOS=0MB physFP=1148MB mallocBlocks=265664 mallocMB=1112 avioFetchedMB=321 cacheCount=64 cacheMB=292 packetsWritten=6144 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=292 muxCuts=64 srvConns=1 srvBytesMB=247 srvSfMB=243 pktAlive=3 pktTotal=32073 subCues=98 audioTracks=1 subTracks=16 subActive=true avBufAhead=7.9s avBufBehind=30.0s frameAhead=0.00s prodShift=-0.08s hostShift=-0.08s seams=1

    [AetherEngine] memprobe t=240s rss=153MB vmInt=68MB vmExt=79MB vmCmp=143MB vmIOS=0MB physFP=230MB mallocBlocks=262624 mallocMB=1343 avioFetchedMB=352 cacheCount=71 cacheMB=324 packetsWritten=6816 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=324 muxCuts=71 srvConns=1 srvBytesMB=280 srvSfMB=276 pktAlive=3 pktTotal=35651 subCues=113 audioTracks=1 subTracks=16 subActive=true avBufAhead=5.8s avBufBehind=32.1s frameAhead=0.00s prodShift=-0.08s hostShift=-0.08s seams=1

  6. superuser404notfound commented on Jul 5, 2026

    @superuser404notfound
    Owner

    Found it, and your memprobe logs are what nailed it. Thank you for the full sequence, they were decisive.

    Here is what they showed. The buckets that split memory apart (cacheMB, muxBytesMB, srvBytesMB, avioFetchedMB) all report the main playback session, and those stayed modest the whole time (cache around 324 MB at the end). Meanwhile mallocMB climbed past 1.3 GB and tracked subActive=true exactly: flat while subtitles were off, rising the moment they came on, back to baseline when they came off. That growth lives outside every main-session bucket, which means it is a second demuxer, not the playback pipeline.

    That is the piece I got wrong in 4.12.0. AetherEngine has two subtitle side demuxers, and I only fixed one of them:

    • The native PiP/AirPlay WebVTT rendition reader (the one 4.12.0 patched with the discard).
    • The on-frame overlay reader, which is what tvOS uses for an embedded text subtitle. This is a separate side demuxer, and it still had no discard. So it went on pulling your file's entire video and audio through its own streaming connection, sample by sample, just to reach the sparse mov_text samples. With 16 subtitle tracks that path is heavy, and the memory scaled with playback position exactly as your logs show.

    Fixed in 4.12.1 (on main now): the overlay reader now discards video and audio on its side demuxer too, so mov_read_packet skips those byte reads entirely and the reader fast-walks the index between cues. I added a regression test that runs a real H.264 + mov_text MP4 through the demuxer and asserts that after the discard only the subtitle samples are read, never the video.

    Could you point your build at 4.12.1 (or main) and retest the same file with subtitles on? mallocMB and RSS should now stay flat as you play, the same way they do with subtitles off. If anything still climbs, one more memprobe run like the ones you already sent will localize it immediately, but this should be it.

  7. cwikstrom22 commented on Jul 5, 2026

    @cwikstrom22
    Author

    It now works beautifully! memory usage is steady and what is to be expected. Thank you so much for the quick fix. Also thank you for such a great engine. I was really struggling with VLC and MPV. I ran across Aether and it pretty much just worked. Amazing job!

  8. superuser404notfound commented on Jul 5, 2026

    @superuser404notfound
    Owner

    Thank you very much ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions