Skip to content

"null function or function signature mismatch" on asyncify'd function used by library #16686

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
Banou26 opened this issue Apr 9, 2022 · 1 comment

Comments

@Banou26
Copy link

Banou26 commented Apr 9, 2022

Version of emscripten/emsdk:
emsdk:3.1.8

Failing command line in full:

	emcc --bind \
	-O3 \
	-L/opt/ffmpeg/lib \
	-I/opt/ffmpeg/include/ \
	-s EXTRA_EXPORTED_RUNTIME_METHODS="[cwrap, ccall, getValue, setValue, writeAsciiToMemory]" \
	-s INITIAL_MEMORY=150mb \
	-s TOTAL_MEMORY=125mb \
	-s TOTAL_STACK=5mb \
	-s ASYNCIFY \
	-s MODULARIZE=1 \
	-s NO_DYNAMIC_EXECUTION=1 \
	-lavcodec -lavformat -lavfilter -lavdevice -lswresample -lswscale -lavutil -lm -lx264 \
	-o dist/libav.js \
	-s SINGLE_FILE=1 \
	src/main.cpp

When using libAV, you need to pass it a readPacket function, which is a static function like so

static int readFunction(void* opaque, uint8_t* buf, int buf_size) {
  auto& remuxObject = *reinterpret_cast<Remuxer*>(opaque);
  remuxObject.read().await();
  return 0;
}


// ...
avioContext = avio_alloc_context(
  buffer,
  avio_ctx_buffer_size,
  0,
  reinterpret_cast<void*>(this),
  &readFunction,
  nullptr,
  &seekFunction
);
// ...

Using an embind .await() inside of that function throws

Uncaught (in promise) RuntimeError: null function or function signature mismatch
    at 00aa48d6:0x1051e8
    at 00aa48d6:0xb58ba
    at 00aa48d6:0xb6e58
    at 00aa48d6:0x1bda07
    at 00aa48d6:0x1be4a8
    at 00aa48d6:0x1a14c8
    at ret.<computed> (libav.js:9:3812847)
    at dynCallLegacy (libav.js:9:3807081)
    at dynCall (libav.js:9:3807167)
    at libav.js:9:3807319

The use of await anywhere else works completly fine, but when used in this callback, it just throws.

@Banou26
Copy link
Author

Banou26 commented Dec 11, 2022

Fixed by #18311

@Banou26 Banou26 closed this as completed Dec 11, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant