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

Can't run webview inside napi asyncWorker #934

Open
boblund opened this issue Apr 24, 2023 · 0 comments
Open

Can't run webview inside napi asyncWorker #934

boblund opened this issue Apr 24, 2023 · 0 comments

Comments

@boblund
Copy link

boblund commented Apr 24, 2023

MacOS Ventura 13.2.1

NodeJS node-addon-api (C++)
Node v18.15.0
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: arm64-apple-darwin22.3.0
Thread model: posix

What did you expect to see and what you saw instead?

I am trying to run webview in a node-addon-api asyncWorker. Here's the code.

const auto html =
    R"html(
	<div id='hi'></div>
	<button id="increment">Tap me</button>
	<div>You tapped <span id="count">0</span> times.</div>
    )html";


SimpleAsyncWorker::SimpleAsyncWorker(Function& callback, int runTime)
    : AsyncWorker(callback), runTime(runTime) {};

void SimpleAsyncWorker::Execute() {
  w.bind("noop", [](std::string s) -> std::string {
    return s;
  });

  w.set_title("Basic Example");
  w.set_size(480, 320, WEBVIEW_HINT_NONE);
  w.set_html(html);
  w.run();
};

I expect a webview running the sample HTML. Instead I get:

node[36401:5455931] *** NSForwarding: warning: object 0x6000010a0000 of class 'WebviewAppDelegate'
     does not implement methodSignatureForSelector: -- trouble ahead
node[36401:5455931] *** NSForwarding: warning: object 0x6000010a0000 of class 'WebviewAppDelegate' 
     does not implement doesNotRecognizeSelector: -- abort

I can run this successfully in node-addon-api without the asyncWorker.

I searched for the cause of this and the nearest I could find was that objectivec and V8 both define a class called 'Object'. Is this the cause? Is there a workaround or is it not possible to run webview asynchronously in a node-addon-api. Any help is appreciated.

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

No branches or pull requests

1 participant