Skip to content

RuntimeError: null function or function signature mismatch #24762

@jinwuwu001

Description

@jinwuwu001

I am compiling C++ code using emsdk 4.0.11, and when calling it on the web, I encounter the following error:

RuntimeError: null function or function signature mismatch
    at hello2d.wasm.dynCall_viid (hello2d.wasm:0xcea710)
    at wrapper (hello2d.js:5554:16)
    at hello2d.js:734:12
    at dynCallLegacy (hello2d.js:1253:10)
    at dynCall (hello2d.js:1258:13)
    at hello2d.js:5296:66
    at BaseView.updateSize (eval at createJsInvoker (hello2d.js:5470:10), <anonymous>:8:1)
    at updateSize (common.ts:221:28)
    at window.onload (index.ts:52:13)

The error seems to be caused by a function signature mismatch, but the same code compiles and works fine when using emsdk 4.0.10 or earlier versions.

The implementation of BaseView.updateSize is as follows:

void BaseView::updateSize(float devicePixelRatio) {
  if (!canvasID.empty()) {
    int width = 0;
    int height = 0;
    emscripten_get_canvas_element_size(canvasID.c_str(), &width, &height);
    auto sizeChanged = appHost->updateScreen(width, height, devicePixelRatio);
    if (sizeChanged && window) {
      window->invalidSize();
    }
  }
}

void BaseView::setImagePath(const std::string& imagePath) {
  auto image = tgfx::Image::MakeFromFile(imagePath.c_str());
  if (image) {
    appHost->addImage("bridge", std::move(image));
  }
}

The binding of BaseView.updateSize is as follows:

#include <emscripten/bind.h>
#include "BaseView.h"
using namespace emscripten;

EMSCRIPTEN_BINDINGS(TGFXDemo) {
  class_<BaseView>("BaseView")
      .function("setImagePath", &BaseView::setImagePath)
      .function("updateSize", &BaseView::updateSize)
      .function("draw", &BaseView::draw);
}

In JavaScript, it is used as follows:

const scaleFactor = window.devicePixelRatio;
BaseView.updateSize(scaleFactor);

What's odd is that setImagePath works fine, but there is an issue specifically with the updateSize function's signature. Can you please help analyze what changes in emsdk 4.0.11 might have caused this problem?

Any insights or suggestions would be greatly appreciated. Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions