woodser / monero-ts

TypeScript library for using Monero
http://woodser.github.io/monero-ts/typedocs
MIT License
198 stars 67 forks source link

Emscription 3.1.56 #198

Open NorrinRadd opened 2 months ago

NorrinRadd commented 2 months ago

This PR resolves https://github.com/woodser/monero-ts/issues/144

woodser commented 2 months ago

Thanks.

Running the sample code, I get this error:

Error [ReferenceError]: asyncifyStubs is not defined
    at LibraryUtils.deserializeError (/Users/woodser/git/monero-ts/dist/src/main/ts/common/LibraryUtils.js:253:106)
    at LibraryUtils.invokeWorker (/Users/woodser/git/monero-ts/dist/src/main/ts/common/LibraryUtils.js:242:26)
    at async MoneroWalletFullProxy.openWalletData (/Users/woodser/git/monero-ts/dist/src/main/ts/wallet/MoneroWalletFull.js:1843:5)
    at async MoneroWalletFull.openWalletData (/Users/woodser/git/monero-ts/dist/src/main/ts/wallet/MoneroWalletFull.js:1602:25)
    at async MoneroWalletFull.openWallet (/Users/woodser/git/monero-ts/dist/src/main/ts/wallet/MoneroWalletFull.js:144:20)
    at async TestUtils.getWalletFull (/Users/woodser/git/monero-ts/dist/src/test/utils/TestUtils.js:232:32)
    at async Context.<anonymous> (/Users/woodser/git/monero-ts/dist/src/test/TestSampleCode.js:32:20)
Worker error: ReferenceError: asyncifyStubs is not defined
    at /Users/woodser/git/monero-ts/dist/dist/monero_wallet_full.js:8:19712
    at Function.loadFullModule (/Users/woodser/git/monero-ts/src/main/ts/common/LibraryUtils.ts:109:70)
    at openWalletData (/Users/woodser/git/monero-ts/src/main/ts/wallet/MoneroWalletFull.ts:1616:37)
    at Function.openWallet (/Users/woodser/git/monero-ts/src/main/ts/wallet/MoneroWalletFull.ts:144:43)
    at apply (/Users/woodser/git/monero-ts/src/main/ts/common/MoneroWebWorker.ts:421:58)
    at self.onmessage (/Users/woodser/git/monero-ts/src/main/ts/common/MoneroWebWorker.ts:49:68)
    1) "before all" hook for "Sample code demonstration"

Which has a related issue which was recently fixed and closed, so hopefully it's in the next release of emscripten: https://github.com/emscripten-core/emscripten/issues/21104#event-12329214343

woodser commented 2 months ago

Please remove the ./dist assets from the PR. Those can be updated and committed later.

NorrinRadd commented 2 months ago

Please remove the ./dist assets from the PR. Those can be updated and committed later.

Done

NorrinRadd commented 2 months ago

Thanks.

Running the sample code, I get this error:

Error [ReferenceError]: asyncifyStubs is not defined
    at LibraryUtils.deserializeError (/Users/woodser/git/monero-ts/dist/src/main/ts/common/LibraryUtils.js:253:106)
    at LibraryUtils.invokeWorker (/Users/woodser/git/monero-ts/dist/src/main/ts/common/LibraryUtils.js:242:26)
    at async MoneroWalletFullProxy.openWalletData (/Users/woodser/git/monero-ts/dist/src/main/ts/wallet/MoneroWalletFull.js:1843:5)
    at async MoneroWalletFull.openWalletData (/Users/woodser/git/monero-ts/dist/src/main/ts/wallet/MoneroWalletFull.js:1602:25)
    at async MoneroWalletFull.openWallet (/Users/woodser/git/monero-ts/dist/src/main/ts/wallet/MoneroWalletFull.js:144:20)
    at async TestUtils.getWalletFull (/Users/woodser/git/monero-ts/dist/src/test/utils/TestUtils.js:232:32)
    at async Context.<anonymous> (/Users/woodser/git/monero-ts/dist/src/test/TestSampleCode.js:32:20)
Worker error: ReferenceError: asyncifyStubs is not defined
    at /Users/woodser/git/monero-ts/dist/dist/monero_wallet_full.js:8:19712
    at Function.loadFullModule (/Users/woodser/git/monero-ts/src/main/ts/common/LibraryUtils.ts:109:70)
    at openWalletData (/Users/woodser/git/monero-ts/src/main/ts/wallet/MoneroWalletFull.ts:1616:37)
    at Function.openWallet (/Users/woodser/git/monero-ts/src/main/ts/wallet/MoneroWalletFull.ts:144:43)
    at apply (/Users/woodser/git/monero-ts/src/main/ts/common/MoneroWebWorker.ts:421:58)
    at self.onmessage (/Users/woodser/git/monero-ts/src/main/ts/common/MoneroWebWorker.ts:49:68)
    1) "before all" hook for "Sample code demonstration"

Which has a related issue which was recently fixed and closed, so hopefully it's in the next release of emscripten: emscripten-core/emscripten#21104 (comment)

👍🏾 is this PR mergeable for now?

woodser commented 2 months ago

is this PR mergeable for now?

For now I'd rather wait to confirm it works in the next release than changing these values in the current release.

NorrinRadd commented 2 months ago

Thanks.

Running the sample code, I get this error:

Error [ReferenceError]: asyncifyStubs is not defined
    at LibraryUtils.deserializeError (/Users/woodser/git/monero-ts/dist/src/main/ts/common/LibraryUtils.js:253:106)
    at LibraryUtils.invokeWorker (/Users/woodser/git/monero-ts/dist/src/main/ts/common/LibraryUtils.js:242:26)
    at async MoneroWalletFullProxy.openWalletData (/Users/woodser/git/monero-ts/dist/src/main/ts/wallet/MoneroWalletFull.js:1843:5)
    at async MoneroWalletFull.openWalletData (/Users/woodser/git/monero-ts/dist/src/main/ts/wallet/MoneroWalletFull.js:1602:25)
    at async MoneroWalletFull.openWallet (/Users/woodser/git/monero-ts/dist/src/main/ts/wallet/MoneroWalletFull.js:144:20)
    at async TestUtils.getWalletFull (/Users/woodser/git/monero-ts/dist/src/test/utils/TestUtils.js:232:32)
    at async Context.<anonymous> (/Users/woodser/git/monero-ts/dist/src/test/TestSampleCode.js:32:20)
Worker error: ReferenceError: asyncifyStubs is not defined
    at /Users/woodser/git/monero-ts/dist/dist/monero_wallet_full.js:8:19712
    at Function.loadFullModule (/Users/woodser/git/monero-ts/src/main/ts/common/LibraryUtils.ts:109:70)
    at openWalletData (/Users/woodser/git/monero-ts/src/main/ts/wallet/MoneroWalletFull.ts:1616:37)
    at Function.openWallet (/Users/woodser/git/monero-ts/src/main/ts/wallet/MoneroWalletFull.ts:144:43)
    at apply (/Users/woodser/git/monero-ts/src/main/ts/common/MoneroWebWorker.ts:421:58)
    at self.onmessage (/Users/woodser/git/monero-ts/src/main/ts/common/MoneroWebWorker.ts:49:68)
    1) "before all" hook for "Sample code demonstration"

Which has a related issue which was recently fixed and closed, so hopefully it's in the next release of emscripten: emscripten-core/emscripten#21104 (comment)

3.1.57 is out, however there still seem to be some issues. It can build the distributable fine. This is output from running npm test on the head of this pr branch. https://gist.github.com/NorrinRadd/d7168dfff5c5293526dd38e12dd388b3

3.1.57 will complain about no thread support if run on the master branch. 3.1.10 runs tests fine on the master branch. 3.1.10 runs tests on the head of this branch fine also: https://gist.github.com/NorrinRadd/6c37d399b4918c8a3a765893b7dcacf1

woodser commented 2 months ago

I'm getting errors running with emscripten 3.1.57:

/Users/woodser/git/monero-ts/build/boost/include/boost/config/requires_threads.hpp:47:5: error: "Compiler threading support is not turned on. Please set the correct command line options for threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)"
   47 | #   error "Compiler threading support is not turned on. Please set the correct command line options for threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)"
      |     ^
In file included from /Users/woodser/git/monero-ts/external/monero-cpp/external/monero-project/src/crypto/crypto.cpp:37:
In file included from /Users/woodser/git/monero-ts/build/boost/include/boost/thread/mutex.hpp:12:
/Users/woodser/git/monero-ts/build/boost/include/boost/thread/detail/platform.hpp:71:9: error: "Sorry, no boost threads are available for this platform."
   71 | #       error "Sorry, no boost threads are available for this platform."
      |         ^
In file included from /Users/woodser/git/monero-ts/external/monero-cpp/external/monero-project/src/crypto/crypto.cpp:37:
/Users/woodser/git/monero-ts/build/boost/include/boost/thread/mutex.hpp:18:2: error: "Boost threads unavailable on this platform"
   18 | #error "Boost threads unavailable on this platform"
      |  ^

Be sure to delete all the build folders before building, and you should see the same error with ./bin/build_all.sh:

rm -rf ./build && rm -rf ./external/monero-cpp/external/boost-sdk && rm -rf ./external/monero-cpp/external/openssl-sdk

NorrinRadd commented 2 months ago

I'm getting errors running with emscripten 3.1.57:

/Users/woodser/git/monero-ts/build/boost/include/boost/config/requires_threads.hpp:47:5: error: "Compiler threading support is not turned on. Please set the correct command line options for threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)"
   47 | #   error "Compiler threading support is not turned on. Please set the correct command line options for threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)"
      |     ^
In file included from /Users/woodser/git/monero-ts/external/monero-cpp/external/monero-project/src/crypto/crypto.cpp:37:
In file included from /Users/woodser/git/monero-ts/build/boost/include/boost/thread/mutex.hpp:12:
/Users/woodser/git/monero-ts/build/boost/include/boost/thread/detail/platform.hpp:71:9: error: "Sorry, no boost threads are available for this platform."
   71 | #       error "Sorry, no boost threads are available for this platform."
      |         ^
In file included from /Users/woodser/git/monero-ts/external/monero-cpp/external/monero-project/src/crypto/crypto.cpp:37:
/Users/woodser/git/monero-ts/build/boost/include/boost/thread/mutex.hpp:18:2: error: "Boost threads unavailable on this platform"
   18 | #error "Boost threads unavailable on this platform"
      |  ^

Be sure to delete all the build folders before building, and you should see the same error with ./bin/build_all.sh:

rm -rf ./build && rm -rf ./external/monero-cpp/external/boost-sdk && rm -rf ./external/monero-cpp/external/openssl-sdk

that is what i get if I run on the master branch. I just ran that rm command and built again on this pr branch and it finished building fine. the new output of npm test is here: https://gist.github.com/NorrinRadd/0cb2b5d81aac0ac23ca751a448f7e385

woodser commented 2 months ago

Excellent, it's building for me too, so I must have done something wrong last time.

So two issues I'm seeing:

  1. Running npm run test -- --grep "TEST MONERO UTILITIES" gives the error "TypeError: _LibraryUtils.default.getWasmModule(...)._free is not a function", which hopefully you can recreate.

  2. Running "Sample code demonstration" in the browser gives error: "ReferenceError: SharedArrayBuffer is not defined". We want to keep the final output single threaded now to avoid these new requirements, until after the emscripten upgrade. I'm hoping this can merely be an emscripten linker flag until we turn it on.

NorrinRadd commented 2 months ago

So two issues I'm seeing:

1. Running `npm run test -- --grep "TEST MONERO UTILITIES"` gives the error "TypeError: _LibraryUtils.default.getWasmModule(...)._free is not a function", which hopefully you can recreate.

I just pushed a fix for this.

2. Running "Sample code demonstration" in the browser gives error: "ReferenceError: SharedArrayBuffer is not defined". We want to keep the final output single threaded now to avoid these new requirements, until after the emscripten upgrade. I'm hoping this can merely be an emscripten linker flag until we turn it on.

I cannot reproduce this. When I press the Sample Code button, nothing happens.

NorrinRadd commented 2 months ago

@woodser ^

woodser commented 2 months ago

npm run test -- --grep "TEST MONERO UTILITIES" is fixed with the malloc and free exports.

Running npm run test -- --grep "Sample code demonstration" fails with error "memory access out of bounds" in node.js and "SharedArrayBuffer is not defined" in the browser.

I think the first step is to ensure this test passes for you before any of these changes (i.e. based on master and with emscripten 3.1.10), so you have a successful baseline.

After that test is passing, you should be able to observe the errors by applying the changes in this PR and updating to the latest emscripten.