Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Auto)Reconnect from unreachable server popup not working #4272

Open
Roffild opened this issue Mar 15, 2024 · 10 comments · May be fixed by #4358
Open

(Auto)Reconnect from unreachable server popup not working #4272

Roffild opened this issue Mar 15, 2024 · 10 comments · May be fixed by #4358
Labels
enhancement New feature or request

Comments

@Roffild
Copy link
Contributor

Roffild commented Mar 15, 2024

The server is already up! How can I disable this window?

bug

The local server may be temporarily unavailable. Why is there no normal server wait? You need to add another server without accidentally clicking.

I want to see a normal page (not a pop-up!) with the inscription:

Waiting for server...

Please return to the server's coverage area or check your connection settings.
@Roffild Roffild added the bug Something isn't working label Mar 15, 2024
@dshokouhi
Copy link
Member

dshokouhi commented Mar 15, 2024

I don't understand the purpose of this issue. The pop-up is telling you the server is inaccessible. Also why is the issue template missing?

@dshokouhi dshokouhi added the question Further information is requested label Mar 15, 2024
@Roffild
Copy link
Contributor Author

Roffild commented Mar 16, 2024

build MinimalDebug

Bug in

alert.setMessage(commonR.string.webview_error)

Start the server after the pop-up.

The SETTINGS button calls up settings. But after returning the page is not updated.

The REFRESH button refreshes the page.

The WAIT button only returns the error again.

@dshokouhi
Copy link
Member

You are still missing the most important part. The logs which may still show an issue, the pop-up only shows up when we get an error if you follow the condition.

@Roffild
Copy link
Contributor Author

Roffild commented Mar 16, 2024

Standard condition:
The server is unavailable when starting the application. This is normal for HA.

It's easy to reproduce the error.

@dshokouhi
Copy link
Member

Please don't skip the logs

@Roffild
Copy link
Contributor Author

Roffild commented Mar 16, 2024

This piece of strange code has no logs!
No Log.d()

@Roffild
Copy link
Contributor Author

Roffild commented Mar 16, 2024

WebView calls a pop-up to update frozen WebView.
It’s better to immediately have a normal mini-webpage with a server poll.

After connecting to the server, reconnection is done through JavaScript without this pop-up.

@jpelgrom
Copy link
Member

So there's no bug here, you are requesting 2 features:

  • If the page has finished loading but didn't load successfully, reload repeatedly to 'improve' the experience
  • A redesign of this dialog which should cover all functionality - you've failed to consider that it will also show is the server is slow to respond but still loading, and options to open settings/switch to internal/external url if you have both set up

@jpelgrom jpelgrom added enhancement New feature or request and removed bug Something isn't working labels Mar 16, 2024
@jpelgrom jpelgrom changed the title AutoReConnect Server unreachable popup changes and automatically reload Mar 16, 2024
@dshokouhi
Copy link
Member

This piece of strange code has no logs!

The pop-up shows up when there is an error connecting to the server or the app did not receive the connection status reported by the frontend. Either case will be reflected in the logs, you either see an error or a 10 second gap for when the pop-up shows up due to no response from the frontend. If the HA frontend reports the connection re-established the app will remove the pop-up. That check is done every 10 seconds.

https://github.com/home-assistant/android/blob/master/app/src/main/java/io/homeassistant/companion/android/webview/WebViewActivity.kt#L1478-L1491

https://github.com/home-assistant/android/blob/master/app/src/main/java/io/homeassistant/companion/android/webview/WebViewActivity.kt#L716-L723

https://developers.home-assistant.io/docs/frontend/external-bus/#connection-status-update-connection-status

@Roffild
Copy link
Contributor Author

Roffild commented Mar 22, 2024

bug.mp4

build MinimalDebug

Bug in

alert.setMessage(commonR.string.webview_error)

alert.setMessage(commonR.string.webview_error)
alert.setPositiveButton(commonR.string.settings) { _, _ ->
    startActivity(SettingsActivity.newInstance(this))
    // NO webView.loadUrl()
}
val isInternal = serverManager.getServer(presenter.getActiveServer())?.connection?.isInternal() == true
alert.setNegativeButton(
    if (failedConnection == "external" && isInternal) {
        commonR.string.refresh_internal
    } else {
        commonR.string.refresh_external
    }
) { _, _ ->
    runBlocking {
        failedConnection = if (failedConnection == "external") {
            serverManager.getServer(presenter.getActiveServer())?.let { webView.loadUrl(it.connection.getUrl(true).toString()) }
            "internal"
        } else {
            serverManager.getServer(presenter.getActiveServer())?.let { webView.loadUrl(it.connection.getUrl(false).toString()) }
            "external"
        }
        // webView.loadUrl() reloads the page!
    }
    waitForConnection() // FAKE! Only checks variables...
}
alert.setNeutralButton(commonR.string.wait) { _, _ ->
    waitForConnection() // FAKE! Only checks variables...
    // NO webView.loadUrl()
}

@Roffild Roffild changed the title Server unreachable popup changes and automatically reload (Auto)Reconnect from unreachable servers popup not working Mar 26, 2024
@Roffild Roffild changed the title (Auto)Reconnect from unreachable servers popup not working (Auto)Reconnect from unreachable server popup not working Mar 26, 2024
@dshokouhi dshokouhi removed the question Further information is requested label Apr 9, 2024
@Roffild Roffild linked a pull request Apr 21, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants