Skip to content

WebAssembly.Module doesn't parse at byte error on iOS #17609

@lizozom

Description

@lizozom

I'm building a wasm project to run on mobile.

I'm using the following CMakeLists configurations:

project(ncnn-webassembly-project)

cmake_minimum_required(VERSION 3.10)

set(CMAKE_BUILD_TYPE release)

set(RUNTIME_OUTPUT_DIRECTORY  ${PROJECT_SOURCE_DIR}/build/)
set(EXECUTABLE_OUTPUT_PATH  ${PROJECT_SOURCE_DIR}/public/)

set(ncnn_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cpp/ncnn/lib/cmake/ncnn")
find_package(ncnn REQUIRED)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s FORCE_FILESYSTEM=1 -s INITIAL_MEMORY=256MB -s EXIT_RUNTIME=1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s FORCE_FILESYSTEM=1 -s INITIAL_MEMORY=256MB -s EXIT_RUNTIME=1")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=15")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=15")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fopenmp -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=15")

# debug
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -sASSERTIONS")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -sASSERTIONS")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -sEXPORTED_FUNCTIONS=['_yolo_ncnn','_detect_yolo','_free'] --preload-file ${CMAKE_CURRENT_SOURCE_DIR}/cpp/assets@.")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -sEXPORTED_FUNCTIONS=['_yolo_ncnn','_detect_yolo','_free'] --preload-file ${CMAKE_CURRENT_SOURCE_DIR}/cpp/assets@.")
set(CMAKE_EXECUTBLE_LINKER_FLAGS "${CMAKE_EXECUTBLE_LINKER_FLAGS} -sEXPORTED_FUNCTIONS=['_yolo_ncnn','_detect_yolo','_free'] --preload-file ${CMAKE_CURRENT_SOURCE_DIR}/cpp/assets@.")


add_executable(duckpuc cpp/proj.cpp)
target_link_libraries(duckpuc ncnn pthread)

add_executable(duckpuc-ios cpp/proj-ios.cpp)
target_link_libraries(duckpuc-ios ncnn pthread)

On Android everything works, but on iOS I get the following errors:

failed to asynchronously prepare wasm: CompileError: WebAssembly.Module doesn't parse at byte 885: can't get 7th argument Type
Aborted(CompileError: WebAssembly.Module doesn't parse at byte 885: can't get 7th argument Type)

Now as far as I understand, threads and atomics are supported on iOS 15.2+, so what else might be the problem?
image

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