Salamek / chromium-kiosk

Chromium kiosk is simple package turning your Archlinux or Debian (and alike) based PC/Raspberry into simple web kiosk using chromium.
GNU General Public License v3.0
60 stars 10 forks source link

RC: On some installs chromium-kiosk&&qiosk boots up sooner than internet connection is established #88

Closed Salamek closed 4 months ago

Salamek commented 5 months ago

This causes the browser to show "No internet..."

Solution add connection check to requested URL before starting qiosk in chromium-kiosk script

OR in qiosk on QWebEngine network error run something like:

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), currentInterval(initialInterval) {

    webEngineView = new QWebEngineView(this);
    webEngineView->setUrl(QUrl("http://example.com"));

    networkManager = new QNetworkAccessManager(this);
    connect(networkManager, &QNetworkAccessManager::finished, this, &MainWindow::handleNetworkReply);

    timer = new QTimer(this);
    connect(timer, &QTimer::timeout, this, &MainWindow::checkUrlAccessibility);
    timer->start(currentInterval);  // Start with initial interval

    connect(webEngineView, &QWebEngineView::loadFinished, this, &MainWindow::handleLoadFinished);

    QWidget *centralWidget = new QWidget(this);
    QVBoxLayout *layout = new QVBoxLayout(centralWidget);
    layout->addWidget(webEngineView);
    setCentralWidget(centralWidget);

    connect(this, &MainWindow::urlAccessible, this, [this]() {
        qDebug() << "URL is accessible. Reloading the page.";
        webEngineView->reload();
        currentInterval = initialInterval; // Reset interval on success
        timer->start(currentInterval);
    });
}

MainWindow::~MainWindow() {
    // Destructor
}

void MainWindow::checkUrlAccessibility() {
    QNetworkRequest request(QUrl("http://example.com"));
    networkManager->get(request);
}

void MainWindow::handleNetworkReply(QNetworkReply *reply) {
    if (reply->error() == QNetworkReply::NoError) {
        emit urlAccessible();
    } else {
        qDebug() << "URL is not accessible.";
        if (currentInterval < maxInterval) {
            currentInterval = qMin(currentInterval + incrementStep, maxInterval);
        }
        timer->start(currentInterval); // Increment the interval
    }
    reply->deleteLater();
}

void MainWindow::handleLoadFinished(bool success) {
    if (!success) {
        qDebug() << "Load finished with error. Checking URL accessibility.";
        checkUrlAccessibility();
    }
}

in a loop

mishoboss commented 4 months ago

Hey Adam, glad you found the issue. I'm doing a nasty workaround to make this work since several months (a script that changes the URL in config 10 seconds after boot).

Do you have a roadmap for this fix?

Salamek commented 4 months ago

@mishoboss fix is actually in qiosk master right now, it just needs to be properly tested before release...

mishoboss commented 4 months ago

I could test it on my setup if you give me a x86 deb file.

Salamek commented 4 months ago

@mishoboss already released in chromium-kiosk 2.5 and qiosk 1.8, check it out