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

No external in Ubuntu 20.04 applications #289

Open
SomeoneToIgnore opened this issue May 25, 2021 · 5 comments
Open

No external in Ubuntu 20.04 applications #289

SomeoneToIgnore opened this issue May 25, 2021 · 5 comments

Comments

@SomeoneToIgnore
Copy link
Contributor

SomeoneToIgnore commented May 25, 2021

I've cloned this repo, navigated into webview-examples and run cargo run --example todo.

Expected: TODO app runs and works
Actual: app starts, but no UI elements are displayed in the app

Seems like there's no external (window.external) object in the page:
image

On the other hand, minimal example works just fine, displaying a Wiki page.
Also both examples work on macOS and Windows for me.

I'm using stock Ubuntu with a few packages installed to successfully compile the examples.

lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.2 LTS
Release:	20.04
Codename:	focal

Is there any way to fix it or at least do debug it further?

@SomeoneToIgnore SomeoneToIgnore changed the title No external in Ubuntu 20.20 applications No external in Ubuntu 20.04 applications Jun 2, 2021
@SomeoneToIgnore
Copy link
Contributor Author

Looks like it's available in window.webkit.messageHandlers.external.postMessage on this platform, so can be workarounded.
But still weird to not to see it available as window.external there too.

@randall-coding
Copy link

This must be the same issue I'm running into #296

@randall-coding
Copy link

randall-coding commented Jul 13, 2021

I wonder if you can help me understand what the implication of this is. Does this mean the Ubuntu 20.04 version of the app should be coded differently? Or is there a way to check and use window.external only when it is available?

@SomeoneToIgnore
Copy link
Contributor Author

SomeoneToIgnore commented Jul 13, 2021

the same issue

Indeed looks like the same issue. What if we close a less detailed one as a duplicate?

Does this mean the Ubuntu 20.04 version of the app should be coded differently?

A bit, yes.
I've used this function as a workaround and it worked fine for me on both macOs and Ubuntu:

function sendMessageToServer(cmd) {
    if (window.external !== undefined) {
        return window.external.invoke(cmd);
    } else if (window.webkit.messageHandlers.external !== undefined) {
        return window.webkit.messageHandlers.external.postMessage(cmd);
    }
    throw new Error('Failed to locate webkit external handler')
}

@randall-coding
Copy link

the same issue

Indeed looks like the same issue. What if we close a less detailed one as a duplicate?

Does this mean the Ubuntu 20.04 version of the app should be coded differently?

A bit, yes.
I've used this function as a workaround and it worked fine for me on both macOs and Ubuntu:

function sendMessageToServer(cmd) {
    if (window.external !== undefined) {
        return window.external.invoke(cmd);
    } else if (window.webkit.messageHandlers.external !== undefined) {
        return window.webkit.messageHandlers.external.postMessage(cmd);
    }
    throw new Error('Failed to locate webkit external handler')
}

Sure thing. Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants