Skip to content

android: startup lag + deep link sometimes resumes old video #281

Description

@Many0therFunctions

Two issues, one fix:

  1. App lags on first launchytDlp().ensureInitialized() runs synchronously on the main thread in OnCreate. It extracts the ytdlp binary + FFmpeg from the APK, blocking the UI thread until it finishes.

  2. Opening a YouTube link sometimes resumes the currently playing video instead of navigating — loadUrl() is called without stopLoading() first, so the previous page can keep playing. The onWindowVisibilityChanged always forcing VISIBLE also prevents YouTube from pausing.

Fix (3 small changes in 2 files):

# NouTubeViewModule.kt — OnCreate
- ytDlp().ensureInitialized() // blocks main thread
+ Executors.newSingleThreadExecutor().execute {
+   ytDlp().ensureInitialized() // runs on background thread
+ }

# NouTubeViewModule.kt — loadUrl
+ view.webView.stopLoading()
  view.webView.loadUrl(url)

# NouTubeView.kt — onWindowVisibilityChanged
- super.onWindowVisibilityChanged(VISIBLE)
+ super.onWindowVisibilityChanged(visibility)

Tested on GrapheneOS (Android 17, Pixel 7 Pro) — startup is snappier and deep links navigate correctly on first tap now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions