On Tue, Oct 18, 2022 at 4:17 AM Sohan Jyoti Ghosh <[email protected]>
wrote:

> Hi !
>
> Thanks for the pointers, the generated JS was indeed very specific.
> We are finally able to load the *.wasm* module with some minor changes in
> the generated JS (loading via module) .
>
> Now, we need help to initialize the native code and invoke the functions
> from JS/HTML ?
>
> The native *Application::Create/HelloWorld* Ctor we try to use needs some
> *platformData*, I wonder how we can provide it from JS/HTML.
>
>
> https://source.chromium.org/chromium/chromium/src/+/main:third_party/skia/example/HelloWorld.cpp;l=29
>
>
> We saw how Canvaskit does the initialization
> https://github.com/google/skia/blob/main/demos.skia.org/demos/hello_world/index.html
>  or
> how Box2D
> https://github.com/kripken/box2d.js/blob/master/demo/webgl/box2d.html#L24
>
> , Bullet(ammo.js)
> https://github.com/kripken/ammo.js/blob/main/examples/webgl_demo/ammo.html#L56
> does.
>
> Are there some other examples we can refer to, to instantiate and control
> C++ objects/functions from JS.
>

There are several different approaches to interacting with native code.  I
would start by reading the docs here:
https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html



> Br,
>
> Sohan
>
> On Fri, Oct 14, 2022 at 1:01 PM Sohan Jyoti Ghosh <[email protected]>
> wrote:
>
>>
>>
>> On Thu, Oct 13, 2022 at 11:39 PM 'Sam Clegg' via emscripten-discuss <
>> [email protected]> wrote:
>>
>>> In general it is not possible to swap the JS and wasm files that
>>> emscripten generates.  The JS is highly specific to the wasm module, and
>>> not portable between wasm modules.
>>>
>>
>> Okay, so the problem with using emscripten toolchain from Skia is that
>> the *.html* file is empty. When we use the template
>> https://github.com/emscripten-core/emscripten/blob/main/src/shell_minimal.html
>> and refer the script to the generated JS. It is not loading the *.wasm* 
>> module
>> (and not throwing any error/warning in the console to understand).
>> Is the *.html *generated also very specific ?
>>
>> We have shared the gist with the JS generated, let us know if anything
>> stands out.
>>
>>>
>>> IIRC many folks have had success compiling skia to wasm already.  Have
>>> you looked at https://skia.org/docs/user/modules/canvaskit/?
>>>
>>
>> Yes, we are following Canvaskit, the use-case here is little different,
>> in that using Canvaskit, the drawing application/code has to be written
>> with Canvaskit API and JS.
>> What we are trying to achieve is a C++ based drawing module using native
>> Skia API's, and the whole package would be compiled to wasm.
>>
>>
>>>
>>>
>>> On Thu, Oct 13, 2022 at 10:21 AM Sohan Jyoti Ghosh <[email protected]>
>>> wrote:
>>>
>>>> Thanks for getting back.
>>>>
>>>> On Thu, Oct 13, 2022 at 7:29 PM 'Sam Clegg' via emscripten-discuss <
>>>> [email protected]> wrote:
>>>>
>>>>> Can you share the full link command you are using?
>>>>>
>>>>> So, we are trying to build the simple skia hello_world c++ app via
>>>> wasm, to be playable inside the browser.
>>>> We are trying to setup the SDL2 backend for skia with
>>>> https://skia-review.googlesource.com/c/skia/+/573643
>>>>
>>>> Here, is our build command for hello_world.wasm, which internally
>>>> invokes emscripten toolchain
>>>> *bazel build //example:hello_world_wasm
>>>> --noincompatible_enable_cc_toolchain_resolution*
>>>>
>>>> Can you take a look at the generated JS file?  Do you see the
>>>>> `_embind_register_void` function in that file?  It should be defined as a
>>>>> function then added to the `asmLibraryArg` object which gets passed to
>>>>> instantiate.
>>>>>
>>>>> The generated JS file (
>>>> https://gist.github.com/sohanjg/a38f509275b84279e98c097c81c9b5e2) doesnt 
>>>> have
>>>> `_embind_register_void`. Also the originally generated files somehow
>>>> wasn't able to load the wasm without throwing errors. So, we changed an
>>>> existing simple emscripten generated helloworld.js (which was almost
>>>> identical) to refer to the wasm generated by skia.
>>>>
>>>> cheers,
>>>>> sam
>>>>>
>>>>> Br,
>>>> Sohan
>>>>
>>>>> On Thu, Oct 13, 2022 at 7:30 AM Sohan Jyoti Ghosh <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> Hi !
>>>>>>
>>>>>> I am getting errors while instantiating Array Buffer,
>>>>>> * WebAssembly.instantiate(binary, info)*
>>>>>>
>>>>>> The error is,
>>>>>> *"Uncaught (in promise) RuntimeError: Aborted(LinkError:
>>>>>> WebAssembly.instantiate(): Import #1 module="env"
>>>>>> function="_embind_register_void" error: function import requires a
>>>>>> callable)"*
>>>>>>
>>>>>> Any pointers, how "env" obj is missing the function ? And how to
>>>>>> resolve it ? I am using the JS template coming out of emscripten.
>>>>>> Is there some error in building the .wasm ?  Nothing is reported on
>>>>>> the build log though.
>>>>>>
>>>>>> Br,
>>>>>> Sohan
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "emscripten-discuss" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>> send an email to [email protected].
>>>>>> To view this discussion on the web visit
>>>>>> https://groups.google.com/d/msgid/emscripten-discuss/1b7778de-a61c-44fe-9b65-3479dfdbbc1dn%40googlegroups.com
>>>>>> <https://groups.google.com/d/msgid/emscripten-discuss/1b7778de-a61c-44fe-9b65-3479dfdbbc1dn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "emscripten-discuss" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/emscripten-discuss/CAL_va29KUrmS82TbqrzuGMU36fZDHdVpJsLG7fne2kg7o9CjqA%40mail.gmail.com
>>>>> <https://groups.google.com/d/msgid/emscripten-discuss/CAL_va29KUrmS82TbqrzuGMU36fZDHdVpJsLG7fne2kg7o9CjqA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "emscripten-discuss" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/emscripten-discuss/CAOtrQ7ys8aWVjkRXCgdyvYvucNkeUhA6BrKEHiUAyj3w7tCJyA%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/emscripten-discuss/CAOtrQ7ys8aWVjkRXCgdyvYvucNkeUhA6BrKEHiUAyj3w7tCJyA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "emscripten-discuss" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/emscripten-discuss/CAL_va2-%2BefpSXiyFkF3KjoHJagX737FSKZuq79prEeQpQGb%3DAQ%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/emscripten-discuss/CAL_va2-%2BefpSXiyFkF3KjoHJagX737FSKZuq79prEeQpQGb%3DAQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/emscripten-discuss/CAOtrQ7yGeQs04mSJSHwHeweW9R%3DdxCYL1JCLm6gUFLf88tsTyg%40mail.gmail.com
> <https://groups.google.com/d/msgid/emscripten-discuss/CAOtrQ7yGeQs04mSJSHwHeweW9R%3DdxCYL1JCLm6gUFLf88tsTyg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/CAL_va29bjWcRp946WbaXnimmConQt61MwU-o7O2W-H6mHFcrQQ%40mail.gmail.com.

Reply via email to