-
Notifications
You must be signed in to change notification settings - Fork 11
Description
I'm running ImmichFrame Android on a cheap Frameo device. After a device reboot, the app displays a black screen when Use WebView? is enabled. The screen remains black indefinitely.
Root Cause
After investigating with diagnostic logging, I found that:
- The app launches before WiFi has connected
- WebView attempts to load the URL with no network available
- WebView "finishes" loading without triggering
onReceivedError- it silently fails - The existing retry logic in
onReceivedErrornever fires, so no retry occurs - Result: permanent black screen
When I disable Use WebView?, the app shows toast messages like "Retrying to fetch server settings... Attempt X of 36" and eventually succeeds once WiFi connects. This confirms the issue is specific to WebView's silent failure behavior.
Background
I understand the previous waitForNetwork check was removed in response to #21, where a VPN user found that Android's NET_CAPABILITY_INTERNET check returned false even when their VPN tunnel was working and could reach the ImmichFrame server.
Proposed Solution
Instead of relying on Android's network validation (which fails for VPN users) or WebView's error callbacks (which don't fire reliably), check actual server reachability before loading the WebView:
fun isServerReachable(url: String): Boolean {
return try {
val client = OkHttpClient.Builder()
.connectTimeout(5, TimeUnit.SECONDS)
.readTimeout(5, TimeUnit.SECONDS)
.build()
val request = Request.Builder().url(url).head().build()
client.newCall(request).execute().use { response ->
response.isSuccessful || response.code in 300..499
}
} catch (e: Exception) {
false
}
}Then retry with toast feedback until the server is reachable.
Why this works for both cases:
- Slow WiFi at boot: Server unreachable → retry until WiFi connects
- VPN users: Once VPN tunnel is up, server is reachable even if Android reports "no internet"
This tests what actually matters: "can I reach my ImmichFrame server?"
I have a working implementation and can submit a PR if this approach is acceptable.