Two issues, one fix:
-
App lags on first launch — ytDlp().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.
-
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.
Two issues, one fix:
App lags on first launch —
ytDlp().ensureInitialized()runs synchronously on the main thread inOnCreate. It extracts the ytdlp binary + FFmpeg from the APK, blocking the UI thread until it finishes.Opening a YouTube link sometimes resumes the currently playing video instead of navigating —
loadUrl()is called withoutstopLoading()first, so the previous page can keep playing. TheonWindowVisibilityChangedalways forcingVISIBLEalso prevents YouTube from pausing.Fix (3 small changes in 2 files):
Tested on GrapheneOS (Android 17, Pixel 7 Pro) — startup is snappier and deep links navigate correctly on first tap now.