Skip to content

OPTI-4942: Sideloaded subtitles - Restart local server after returning from background - #130

Merged
therama merged 6 commits into
mainfrom
bugfix/OPTI-4942-server-restart
Nov 3, 2026
Merged

therama merged 6 commits into
mainfrom
bugfix/OPTI-4942-server-restart

Conversation

@ceyhun-o

Copy link
Copy Markdown
Contributor

Summary
Restarts the connector's local subtitle server when the app returns to the foreground if the server is no longer reachable. Also stops old servers from being left running.

Problem

  • SRT tracks, tracks with vttTimestamp, and tracks with automatic timestamp sync are served by a local server. iOS can close that server's socket while the app is in the background. The connector didn't handle this, so subtitles failed to load after returning to the app.
  • Old servers and loaders were never released when the source was replaced.

Solution

  • On foreground, check whether the server responds. If it doesn't, restart it on the same port, so existing subtitle URLs keep working.
  • A healthy server is left alone.
  • Old servers and loaders are now released when the source is replaced.

Tests done

  • Added unit tests; all 11 tests pass. iOS and tvOS builds succeed.
  • Tested on an iPhone 13 mini (on iOS 27.2) and an Apple TV 4K (on tvOS 27.0).

ceyhun-o and others added 4 commits October 27, 2026 13:52
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@ceyhun-o
ceyhun-o requested a review from therama October 28, 2026 10:59
Swifter defaults to background QoS, which starved the local server's request handling and its nested subtitle fetch for tens of seconds on a loaded system (seen as timeouts on CI).

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
The foreground reachability check now runs asynchronously and restarts the server on the main thread when it fails.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@therama
therama merged commit afe70cc into main Nov 3, 2026
2 checks passed
@ceyhun-o
ceyhun-o deleted the bugfix/OPTI-4942-server-restart branch November 3, 2026 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants