RuntimeError when encoding to UASTC with WASM

Aperta
#356 1 commento 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
cmake, wasm
Ambito
build-system

Direzione di ricerca

Start with webgl/encoder/README.md to reproduce the WASM encoder build, then inspect webgl/encoder/CMakeLists.txt at the LINK_FLAGS setting named in the issue. Check how STACK_SIZE affects UASTC encoding and whether 10 MB is appropriate; done means the reported out-of-bounds memory error is resolved with a justified stack size.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

compile fix
Description
  • Windows Version 10.0
  • Clone the current state (this commit at the time of writing this)
  • Clone the current emsdk (this commit at the time of writing this)
  • Use LLVM version 12.0.0 (if that matters)
  • Run the emsdk_env.bat to set up the PATH
  • Compile the encoder, as described in the webgl/encoder/README.md
    The result will be the basis_encoder.js and wasm files, attached here for reference:
    basis_encoder-build.zip
  • Serve the /webgl directory with a local server
  • Visit http://localhost:..../encode_test/
  • Select the UASTC check box
  • Hit 'Encode!'

The console shows

basis_encoder.wasm:0x36da2 Uncaught RuntimeError: memory access out of bounds
    at basis_encoder.wasm:0x36da2
    at basis_encoder.wasm:0x282a3
    at basis_encoder.wasm:0x14223
    at basis_encoder.wasm:0xb0c
    at basis_encoder.wasm:0xd7983
    at basis_encoder.wasm:0xd72a5
    at ClassHandle.BasisFile$getFileDesc [as getFileDesc] (eval at newFunc (basis_encoder.js:8:81985), <anonymous>:8:10)
    at dumpBasisFileDesc ((index):160:33)
    at dataLoaded ((index):230:3)
    at PNGDataLoaded ((index):471:3)

This happens on Chrome 116.0 and FireFox 117.0, and the same error appears when using the build output in Node.js, so it seems to be a general issue.

Possible solution

After a bunch of trial and error, I stumbled over https://github.com/emscripten-core/emscripten/issues/19268#issuecomment-1544298860 , and after changing the LINK_FLAGS in the CMakeLists.txt to include the STACK_SIZE like this...

LINK_FLAGS "--bind -s ALLOW_MEMORY_GROWTH=1 -O3 -s ASSERTIONS=0 -s INITIAL_MEMORY=299958272 -s MALLOC=emmalloc -s MODULARIZE=1 -s EXPORT_NAME=BASIS -s STACK_SIZE=10MB")

... the problem no longer appears.

If others confirm that this makes sense (or add details, like which other size than 10MB might be more appropriate), I can create a corresponding PR.

Lingua principale
C++
Stelle
3.1k
Fork
347
Merge medio
4g 3h
PR unite (30g)
1

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di BinomialLLC/basis_universal

Tutte le issue di BinomialLLC/basis_universal

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.