Boxedwine icon indicating copy to clipboard operation
Boxedwine copied to clipboard

Build Js multithreaded seems to fail

Open momo-AUX1 opened this issue 1 year ago • 27 comments

Build JS multithreaded seems to fail due to undefined because it's looking for undefined does anyone know why?

Built with the latest EMScripten as of today with mingw on windows 10

momo-AUX1 avatar Oct 29 '24 04:10 momo-AUX1

@momo-AUX1 I probably shouldn't have checked in that build script or maybe I should have put a note on it. It's just an experiment. I did get it to work on a slightly older version of emscripten, but it didn't run for more than a few seconds. In my proof of concept it wasn't any faster, but I have some ideas of how to improve the code.

We need a newer version of emscripten to work with multi-threaded, but the newer versions of emscripten broke file handling. My goal is to get Boxedwine working on the newest Emscripten, but I don't have a time frame for that. It would be nice if I can get it done and make my next release of Boxedwine in January for Wine 10 release.

Here is my experiment of multi-threaded using Emscripten 3.1.61

https://www.boxedwine.org/v/mt/kevin61mt/boxedwine.html?app=mdk&p=PERF_W95.EXE

danoon2 avatar Oct 31 '24 15:10 danoon2

Amazing work! I recently ported this specific EMScripten app to Xbox what are some general optimization flags do you recommend?

As for the multithreaded version, I'll keep updating it and make sure it matches the latest BoxedWine release it's currently at Debian10+wine5.0

Thank you very much for your hard work!

momo-AUX1 avatar Oct 31 '24 17:10 momo-AUX1

@momo-AUX1 Do you mean the emscripten build is running on xbox instead of the native c++ version?

danoon2 avatar Oct 31 '24 19:10 danoon2

Indeed the native version would've been a huge task to get it working, but the EMScripten version with some tweaks got up and running! That's why I'm hoping we'd see a multithreaded JS build or any optimizations on that front I could send you the app to test if needed

momo-AUX1 avatar Nov 01 '24 05:11 momo-AUX1

@momo-AUX1 I was curious and just looked into compiling for xbox. https://wiki.libsdl.org/SDL2/README/gdk It seems like there are a lot of hoops to jump through. I was hoping to see just a simple build on windows with an emulator on windows, something more like iPad development. I guess not.

danoon2 avatar Nov 01 '24 16:11 danoon2

There is a SDL for UWP (https://github.com/aerisarn/SDL-uwp-gl) although I wouldn't really know what wine would need on top of SDL so I didn't really attempt it sadly.

However I have a question, what are some optimization flags that you recommend for xbox/EMSscripten? And could boxedwine support Linux apps or is it windows only?

momo-AUX1 avatar Nov 01 '24 17:11 momo-AUX1

Boxedwine uses SDL for windows, drawing, mouse, etc. So for the c++ port to XBox, SDL would need to be included.

Boxedwine does not support Linux apps that have a UI. For command line stuff, it can work.

danoon2 avatar Nov 01 '24 18:11 danoon2

There are no optimization I can think of for the Emscripten build. We have always struggled with performance for that. I keep hoping someone would bring a JIT to the Dosbox port of Emscripten that I could use as a reference.

danoon2 avatar Nov 01 '24 18:11 danoon2

Either way, the reception for it on xbox has been stellar you could expect a video about it to be released soon! I'll keep on maintaining it to the latest EMScripten build so the users can benefit with. big disclaimer about performance for now

momo-AUX1 avatar Nov 01 '24 19:11 momo-AUX1

emscripten multithreaded build is now functional with latest emscripten. build with command: makefile multiThreaded

kevodwyer avatar Jan 27 '25 04:01 kevodwyer

Amazing news, I'll make sure to rebase the Xbox on this version. Would you happen to know what's the perf gains compared to the old build ?

momo-AUX1 avatar Jan 27 '25 09:01 momo-AUX1

@momo-AUX1 also, if you are building yourself, you can now use the latest, 4.0 for emscripten. The multi-threaded normal CPU core is about 50%-100% faster on other platforms and even more importantly, it should feel more responsive with less tiny pauses in the UI. In my limited testing on emscripten, it looks like this will be the case for emscripten too.

danoon2 avatar Jan 27 '25 16:01 danoon2

Understood you can expect it done today or tomorrow I will test all the new improvements thoroughly on Xbox and report them

momo-AUX1 avatar Jan 27 '25 16:01 momo-AUX1

Looks like it's failing to read my zip file which otherwise worked back then it says this :

boxedwine.zip depends on debian10.zip, and debian10.zip could not be found
Using zip file system: boxedwine.zip
Using zip file system: boxedwine.zip/debian10.zip
Loaded boxedwine.zip in 5332 ms
Could not load zip file: boxedwine.zip/debian10.zip
Could not read file global info from zip file: boxedwine.zip/debian10.zip
Loaded boxedwine.zip/debian10.zip in 29 ms
wine: Unhandled page fault on read access to FFFFFFFF at address D120B126 (thread 0009), starting debugger...
boxedwine-shell.js:613 Can't attach process 0008: error 5
boxedwine-shell.js:613 winedbg: Internal crash at 0xd124b126

I also do see it uses significantly more memory and the threads are there just hoping it works on xbox, the new header will need some solving.

If you have a spare FS zip I could test to confirm it isn't a zip issue I'll be glad to try it out

momo-AUX1 avatar Jan 28 '25 19:01 momo-AUX1

@momo-AUX1 You can use the build artifact found here. The WINE file system you want is in the Web directory called boxedwine.zip

kevodwyer avatar Jan 29 '25 03:01 kevodwyer

@kevodwyer looks like it was indeed a zip issue your build artifact works perfectly, could you please link me to a guide on how to make a full debian10 system again? I seriously don't know how the zip suddenly started failing after it worked

momo-AUX1 avatar Jan 29 '25 06:01 momo-AUX1

boxedwine-shell.js:625 TypeError: Cannot read properties of undefined (reading 'audioContext')

Looks like it fails to load audio for the game I tested which was paintball from the XP classics

Also the blue background is behind the window is that intentional ?

I'm guessing it's because it's a beta build but so far performance is really great

momo-AUX1 avatar Jan 29 '25 12:01 momo-AUX1

@momo-AUX1 The full Wine 6.0 file system can be downloaded from here

http://www.boxedwine.org/v2/2/TinyCore15Wine6.0.zip

the paintball game is not full screen, so it's normal that there would be a blue desktop behind it. But if it looks odd, can you post a screen shot?

danoon2 avatar Jan 29 '25 16:01 danoon2

Image

as you see the desktop background is white and the background is blue? even though I forced it to be 100vh and 100vw the css code that works correctly resizes the main window but the background still stays for some reason can at least say it's specific to the code and not the OS since 3 zips and the same issues are present

momo-AUX1 avatar Jan 29 '25 17:01 momo-AUX1

@momo-AUX1 It looks like the explorer shell is not taking up the entire screen. You can tell by the gray bottom bar not going all the way across.

If you know the resolution you will need, you can tell the shell what size to be by launch it with something like

/bin/wine explorer /desktop=shell,1024x786

danoon2 avatar Jan 29 '25 19:01 danoon2

Just tried this:

http://localhost:8000/boxedwine.html?resolution=1280x720&app=pinball.zip


Command line arguments: "./this.program" "-root" "/root" "-zip" "TinyCore15Wine6.0.zip" "-mount" "pinball.zip" "/home/username/.wine/dosdevices/c:/files" "-mount_drive" "/d_drive" "d" "-resolution" "1280x720" "/bin/wine" "explorer" "/desktop=shell, 1280x720"

Doesn't seem to change anything I'll try compiling a non MT version and see if this still persists

momo-AUX1 avatar Jan 29 '25 19:01 momo-AUX1

@momo-AUX1 Last thing I can think of, you should change

"/desktop=shell, 1280x720"

to

"/desktop=shell,1280x720"

no space after comma

danoon2 avatar Jan 29 '25 19:01 danoon2

becomes just a white page sadly

momo-AUX1 avatar Jan 29 '25 20:01 momo-AUX1

I don't know if you guys saw this but will you consider using it to maybe run GL on EMS?

https://github.com/ptitSeb/gl4es

this project uses it in WASM to run quake

https://github.com/GMH-Code/Qwasm

momo-AUX1 avatar Mar 02 '25 09:03 momo-AUX1

It seems like running OpenGL on Emscripten is hit or miss. I get the feeling the lower the OpenGL version the better. Quake 1 and Quake 2 both used a pretty low version of OpenGL. I think Quake 1 used OpenGL 1.1, with GLQuake using a subset of that called MiniGL. Interestingly, 3dfx had an OpenGL driver for their card, but it wasn't complete, it seemed like it implemented just enough to run Quake.

On Emscripten's page, https://emscripten.org/docs/porting/multimedia_and_graphics/OpenGL-support.html, it states "support for a number of legacy GL 1.x features and commands."

So without a wrapper, it might be possible to run some OpenGL 1.x stuff in Emscripten.

Emscripten: "OpenGL ES 2.0/3.0 emulation support for some emulated OpenGL ES 2.0/3.0 features that are not present in WebGL."

So with an ES wrapper, it might be possible to get farther.

As far as running Boxedwine with 3D support in Emscripten? I have been thinking of this lately and haven't had much luck. In Wine 3.0, https://www.winehq.org/announce/3.0, they stated

Android:

  • OpenGL is supported, but it's limited to the OpenGL ES API that is available on Android.

  • Direct3D is not supported yet, because it cannot run on top of OpenGL ES at this point. This will be addressed during the next development cycle.

But then nothing, I don't see android and Direct3D mentioned again. So I guess it wasn't a priority or it is just a really difficult problem. Around that time they pivoted to getting Direct3D on Vulkan to run.

At this point I was hoping to find a direct 3d 1-8 wrapper that converted to OpenGL ES, but I don't think that ever existed. The closest I got was https://dxgl.org/, which can run directx 1-7 on OpenGL 2.0. But I haven't had much luck running that in Boxedwine. It crashes an OpenGL call, I'm not sure if that's my fault or not. I may look into that more, but I don't have much hope that OpenGL 2.0 would run in Emscripten. But maybe dxgl on gl4es on emscripten?

So, while Quake running GL in Emscripten is interesting, I think its the easiest case possible because Quake doesn't use the full OpenGL 1.1 spec and its such an old version of OpenGL. Getting DirectX 1-8 should be easier that DirectX 9, but so far I haven't had any luck.

I think software emulation might be the way to go. Swiftshader sounds promising

https://github.com/ddrmax/swiftshader-ex

But compiling this for win32 and running in Boxedwine will probably be pretty slow.

danoon2 avatar Mar 02 '25 15:03 danoon2

Yeah it might be slower but great for compatibility I'm hoping browsers or devices will get better to eventually compensate for the software renderer.

momo-AUX1 avatar Mar 02 '25 18:03 momo-AUX1

@momo-AUX1 I agree. I got Mesa LLVM software OpenGL to run on Arm Mac and win32/win64/arm64 Windows. For the older games, it runs pretty well.

danoon2 avatar Mar 02 '25 22:03 danoon2