Giter Club home page Giter Club logo

csharp-wasm's People

Contributors

lodicolo avatar

Watchers

 avatar  avatar  avatar

csharp-wasm's Issues

HelloCallback throws System.OutOfMemoryException when passing C# callback into native library

Callback passing into native library currently does not work (currently blocking my ability to consume emscripten_fetch), minimal reproduction scenario is can be found in HelloCallback 7987aa98b8

Delegate and extern declarations:

    unsafe internal delegate void HelloCallback(int result);

    [DllImport("hello_callback")] unsafe extern internal static void helloCallback(int number, string str, HelloCallback callback);

Inline static method declaration and call into native code supplying the function (the inline as opposed to separate method declaration did not change the result):

            static void testCallback(int result)
            {
                Console.WriteLine($"from C#: Received {result} from C library callback");
            }

            // This completely blows up with the following, the native printf() is never hit:
            // System.OutOfMemoryException: Insufficient memory to continue the execution of the program.
            helloCallback(123, "abc", testCallback);

Relevant stacktrace:

System.OutOfMemoryException: Insufficient memory to continue the execution of the program.
   at S.P.CoreLib.Internal.Runtime.Augments.RuntimeAugments.CreateThunksHeap (http://localhost:8000/HelloCallback.wasm:wasm-function[4636]:0x2a4c30 undefined)
   at S.P.CoreLib.System.Runtime.InteropServices.PInvokeMarshal.AllocateThunk (http://localhost:8000/HelloCallback.wasm:wasm-function[4634]:0x2a47a0 undefined)
   at S.P.CoreLib.System.Runtime.CompilerServices.ConditionalWeakTable.2.CreateValueCallback<System..Canon.System..Canon>.InvokeOpenStaticThunk (http://localhost:8000/HelloCallback.wasm:wasm-function[4635]:0x2a4b06 undefined)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.