Comments (3)
Adding -s WASM to CMakeFiles.txt LINK_FLAGS, it builds but cannot test locally due to promise fetch API:
craft.js:1806 Fetch API cannot load file:////NetCraft/build/craft.wasm. URL scheme must be "http" or "https" for CORS request.
Uncaught (in promise) TypeError: Failed to fetch
at getBinaryPromise (craft.js:1806)
at doNativeWasm (craft.js:1877)
at Object.Module.asm (craft.js:2027)
at craft.js:9827
run from a local server:
python -m SimpleHTTPServer
then http://localhost:8000/craft.html - this works in Chrome 57.0.2987.133, and seems snappier. The wasm build output with emscripten is a lot smaller:
build $ ls -lh craft*
-rw-r--r-- 1 admin staff 100K Apr 4 22:24 craft.html
-rw-r--r-- 1 admin staff 1.1M Apr 4 22:24 craft.js
-rw-r--r-- 1 admin staff 2.6M Apr 4 22:24 craft.wasm
than the asm.js emscripten output:
build $ ls -lh craft*
-rw-r--r-- 1 admin staff 100K Apr 4 22:32 craft.html
-rw-r--r-- 1 admin staff 14M Apr 4 22:32 craft.js
1.1M + 2.6M = 3.7M for wasm vs 14M for asm.js. But the downside is less browser compatibility, just hangs in Safari Technical Preview. So the asm.js-based emscripten build would still be needed.
Question now is how to integrate this variant into the build system. Make it a cmake option (to add to the arguments of cmake -DCMAKE_TOOLCHAIN_FILE=$EMSCRIPTEN/cmake/Modules/Platform/Emscripten.cmake ..
)? Or maybe better, always build both asm.js and wasm (run build twice?), then load either with a fallback?
from netcraft.
Added for GH-45 and this a wasm build type:
mkdir wasm-build
cmake -DWASM=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$EMSCRIPTEN/cmake/Modules/Platform/Emscripten.cmake ..
make
However, wasm used to work, when I first tried it -- but now, get an out-of-memory access?!
craft.html:1251 exception thrown: RuntimeError: memory access out of bounds,RuntimeError: memory access out of bounds
at ([273]+70)
at ([279]+40)
at Object.Module._main (http://localhost:8000/craft.js:1:827350)
at Object.callMain (http://localhost:8000/craft.js:1:836819)
at doRun (http://localhost:8000/craft.js:1:837562)
at http://localhost:8000/craft.js:1:837712
What changed? Need to regress to 4/4, isolate
cp CMakeLists.txt /tmp
git checkout CMakeLists.txt
git checkout X
cp /tmp/CMakeLists.txt .
cd wasm-build
rm craft* ; make ; ls -l craft.wasm && python -m SimpleHTTPServer
works:
fails to compile (missing conditional compilation for web):
- aa99147 Add fullscreen/windowed toggle with F11 using glfwSetWindowMonitor()
broken (memory access out of bounds error):
so it's something from aa99147 or 999ac5e? Wouldn't have expected it...
Starting with aa99147 and commenting out native calls so it compiles:
--- a/src/main.c
+++ b/src/main.c
@@ -2430,13 +2430,13 @@ void get_fullscreen_monitor_dimensions() {
}
void fullscreen_exit() {
- glfwSetWindowMonitor(g->window, NULL, g->window_xpos, g->window_ypos, g->window_width, g->window_height, GLFW_DONT_CARE);
+ //glfwSetWindowMonitor(g->window, NULL, g->window_xpos, g->window_ypos, g->window_width, g->window_height, GLFW_DONT_CARE);
}
void fullscreen_enter() {
glfwGetWindowPos(g->window, &g->window_xpos, &g->window_ypos);
glfwGetWindowSize(g->window, &g->window_width, &g->window_height);
- glfwSetWindowMonitor(g->window, g->fullscreen_monitor, 0, 0, g->fullscreen_width, g->fullscreen_height, GLFW_DONT_CARE);
+ //glfwSetWindowMonitor(g->window, g->fullscreen_monitor, 0, 0, g->fullscreen_width, g->fullscreen_height, GLFW_DONT_CARE);
}
void create_window() {
wasm does crash with RuntimeError: memory access out of bounds,RuntimeError: memory access out of bounds, so, it is something added in this commit
Found it: get_fullscreen_monitor_dimensions(). This calls glfwGetPrimaryMonitor() and indexes the video modes array, certainly not needed for the web. The variables it sets weren't being used on the web (native only, where there are monitors) so execution was harmless except for the out-of-bounds memory accesses it caused.
from netcraft.
from netcraft.
Related Issues (20)
- Cookie to save login session?
- Screenshots look brighter than they are - saving alpha channel? HOT 1
- Liquids should target block underneath when mining HOT 2
- Crouching with shift should allow sliding along edges
- Crouching while falling but not flying allows hovering midair
- [VR] Use window size as vr size, allow resizing by retoggling to reinitialize
- Touch controls should allow full game interaction
- Use only terrain from server, remove local generation when online
- Update glfw to fix build and runtime warnings HOT 1
- Touch events not received on initial page load
- /list command to list player names and count online
- [VR] Google Cardboard support
- [Touch] Block should mine only when touching in same place without moving
- Showing chunk boundary borders
- View bobbing when walking HOT 1
- Rendered arm of player in first person HOT 1
- Crafting HOT 1
- Try out "Voxelus"? HOT 1
- Texture Management Change
- Build failing on Linux when building LLVM from source HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from netcraft.