[00:47] *** taisel has joined #jsmess [00:47] sup [00:48] On my new rig, it eats js emulators for breakfast [00:48] even did experiments comparing it to a 2.4 ghz core 2 duo/penryn [00:48] 6700k OC'd to 4.8 ghz with 3200mhz ram [00:49] core 2 duo is like 41% slower clock for clock [00:49] after accounting for frequency [00:49] I guess that stat is useful for legacy computer support [02:26] *** taisel has quit IRC (Quit: ChatZilla 0.9.92 [Firefox 48.0.2/20160823121617]) [04:33] *** godane has quit IRC (Quit: Leaving.) [04:34] *** godane has joined #jsmess [05:09] *** balrog has quit IRC (Read error: Operation timed out) [05:13] *** balrog has joined #jsmess [05:20] *** taisel has joined #jsmess [05:38] *** taisel has quit IRC (Quit: ChatZilla 0.9.92 [Firefox 52.0a1/20160920030429]) [10:05] *** db48x has joined #jsmess [10:05] howdy [10:39] Hi, sir. [10:42] So, want the general makeup of what's going on with this? [10:43] I'll go ahead with it. [10:43] sure [10:44] Basically, we had a pretty connected guy who has done some amazing stuff, and he did some Apple II work, which I got attention for, which he appreciates, and so on and so on. [10:44] As part of that, I shoved his Apple II program into the IA/Emularity, which meant that it was there, but then he went to it and went WELL GUESS WHAT HE WENT [10:45] Something not unlike complete confusion that an Apple II was causing his laptop fan to go on [10:45] So I threw him down the hole, he emerged with lots of thoughts. I'll forward those if you didn't get them, I forget. [10:45] Of all the thoughts, one of them was "have you tried web workers" [10:45] And of course bai pointed at his arm and went "and that's how I got THIS scar" [10:46] :) [10:46] But regardless, the claims were that maybe it's a little better, a little more realistic. [10:46] So along that line, we did it, we recompiled using the web workers approach. [10:46] And we're hitting some errors, etc. [10:46] Now, I brought in some folks to help and we sort of got it crashing in a different place [10:46] You're welcome to throw all that out but it's worth looking at, I think. [10:47] fun [10:47] yea, I'd like to take a look at everything [10:47] http://fos.textfiles.com/dfjustin/jaguar/jaguar/ is the classic "let's make this poor thing kill a browser" bench [10:47] http://fos.textfiles.com/dfjustin/jaguar/jaguar-workers/ is us compiling for a web worker. [10:47] Now, multiple things happened. [10:48] 1. The thing compiled as mamejaguar.js instead of messjaguar, so we had to do a little sed magic in there. [10:48] 2. A web worker has no window (right now) and so we had to do a local variable [10:48] 3. The web worker apparently needs to be reminded of things like functions and the rest. The main callers gives it nothing. [10:49] So this has fingerprints of all sorts of attempts to make that work. [10:49] To stress, though, we're just trying to get it working enough that: [10:49] 1. It's using the web worker structure [10:49] 2. It reasonably does so (puts them in separate threads) to see if this has a speed difference [10:50] We don't want pretty, just meatball right now [10:50] If we see some significant jump, like suddenly we're rocking the house at 100% on Jaguar, then it's worth cleaning up all the meatball [10:51] But if we do it, it's showing as working in two threads, the communication between the two is sucking up the processing, and THEN we show it to Alon and go "is this normal" and he goes "yeah, kind of is", then this experiment is dead. [10:52] As most people seemed to want to chew through a whale carcass than do this, I can happily say that the thing sitting in jaguar-workers is all my mess with a guy named Yoz helping me. [10:55] hrm [10:55] Happy to walk back and start from scratch with another directory, too. [10:58] I don't see anything obviously wrong with it [10:59] except that there's no sourcemap for the minified file [11:02] which makes debugging the current failure rather hard [11:03] You tell me what to do and I'll do it. [11:03] http://fos.textfiles.com/dfjustin/jaguar/jaguar-workers/head.txt [11:03] So, this is shoved in the first line of the worker program. [11:08] Forwarded to your e-mail is the information germaine to the web worker discussion. [11:08] Including a link from Alon of the vaguely hacky things they've done to get their javascript first person shooter demo working. [11:13] So, in my cargo-culty way, I see the jaguar worker emulator saying: [11:13] mamejaguar.worker.js:2 Uncaught TypeError: Cannot read property 'requestPointerLock' of undefined at _emscripten_get_pointerlock_status [11:13] Which tells me that it's not being handed the driving for the Pointerlock. [11:28] interesting, I get a different error [11:38] Mine's on chrome. [12:21] can you try rebuilding mame with DEBUG=1? [12:21] Sure. [12:21] One moment. [12:21] (For various values of "one moment" [12:24] Well, I type rm * instead of rm thing, so that just set me back. [12:24] Give me a moment. [12:31] :) [12:34] meanwhile I'm reinstalling emscripten [12:34] You'll pardon me while I do a build of this item the "normal" way to make sure I didn't completely blow away my environment. [12:35] As for the machines build order list, I think I'll write a script to generate it this time, then save the script off somewhere. :) [12:44] So, http://fos.textfiles.com/dfjustin/jaguar/newjaguar/ proves that it works. [12:44] (The fixing the mess I just made.) [12:48] did you compile that one with --proxy-to-worker as well? [12:48] No. [12:48] No, no. [12:48] ah [12:48] That was just me proving I didn't just destroy the system to the point that it didn't work normally anymore. [12:48] ah, ok [12:48] Always good to check the base sets [12:48] Otherwise you'd choke me out when it turned out I'd hammered it. [12:48] I have to go into MAME directly and do these settings, so let me go do that. [12:49] I get to play "where do I set the compile targets again" [12:52] It's mame/scripts/src/main.lua, by the way. [12:53] configuration { "asmjs" } [12:53] targetextension ".bc" [12:53] if os.getenv("EMSCRIPTEN") then [12:53] local emccopts = "" [12:53] .. " -O" .. _OPTIONS["OPTIMIZE"] [12:53] .. " -s USE_SDL=2" [12:53] .. " -s USE_SDL_TTF=2" [12:53] .. " --memory-init-file 0" [12:53] .. " -s ALLOW_MEMORY_GROWTH=0" [12:53] .. " -s TOTAL_MEMORY=268435456" [12:53] .. " -s DISABLE_EXCEPTION_CATCHING=2" [12:53] .. " -s EXCEPTION_CATCHING_WHITELIST='[\"__ZN15running_machine17start_all_devicesEv\",\"__ZN12cli_frontend7executeEiPPc\"]'" [12:53] .. " -s EXPORTED_FUNCTIONS=\"['_main', '_malloc', '__Z14js_get_machinev', '__Z9js_get_uiv', '__Z12js_get_soundv', '__ZN15mame_ui_manager12set_show_fpsEb', '__ZNK15mame_ui_manager8show_fpsEv', '__ZN13sound_manager4muteEbh', '_SDL_PauseAudio', '_SDL_SendKeyboardKey']\"" [12:53] .. " --pre-js " .. _MAKE.esc(MAME_DIR) .. "src/osd/modules/sound/js_sound.js" [12:53] .. " --post-js " .. _MAKE.esc(MAME_DIR) .. "scripts/resources/emscripten/emscripten_post.js" [12:53] .. " --embed-file " .. _MAKE.esc(MAME_DIR) .. "bgfx/chains@bgfx/chains" [12:53] .. " --embed-file " .. _MAKE.esc(MAME_DIR) .. "bgfx/effects@bgfx/effects" [12:53] .. " --embed-file " .. _MAKE.esc(MAME_DIR) .. "bgfx/shaders/gles@bgfx/shaders/gles" [12:53] .. " --embed-file " .. _MAKE.esc(MAME_DIR) .. "artwork/slot-mask.png@artwork/slot-mask.png" [12:54] I think I rewrote my make-maker so it works. [12:55] So it's compiling now, with --proxy-to-worker and DEBUG=1 [12:55] I hope. I'll watch. [13:03] /0/home/dfjustin/emscripten/emcc -O3 -s USE_SDL=2 -s USE_SDL_TTF=2 --memory-init-file 0 -s ALLOW_MEMORY_GROWTH=0 -s TOTAL_MEMORY=268435456 -s DEBUG=1 --proxy-to-worker -s DISABLE_EXCEPTION_CATCHING=2 -s EXCEPTION_CATCHING_WHITELIST='["__ZN15running_machine17start_all_devicesEv","__ZN12cli_frontend7executeEiPPc"]' -s EXPORTED_FUNCTIONS="['_main', '_malloc', '__Z14js_get_machinev', '__Z9js_get_uiv', '__Z1 [13:03] 2js_get_soundv', '__ZN15mame_ui_manager12set_show_fpsEb', '__ZNK15mame_ui_manager8show_fpsEv', '__ZN13sound_manager4muteEbh', '_SDL_PauseAudio', '_SDL_SendKeyboardKey']" --pre-js /0/JSMESS/mame/src/osd/modules/sound/js_sound.js --post-js /0/JSMESS/mame/scripts/resources/emscripten/emscripten_post.js --embed-file /0/JSMESS/mame/bgfx/chains@bgfx/chains --embed-file /0/JSMESS/mame/bgfx/effects@bgfx/effects [13:03] --embed-file /0/JSMESS/mame/bgfx/shaders/gles@bgfx/shaders/gles --embed-file /0/JSMESS/mame/artwork/slot-mask.png@artwork/slot-mask.png ../../../../../jaguar.bc -o /0/JSMESS/mame/mamejaguar.js [13:03] Looking good. [13:05] hrm, except that didn't do what I expected [13:05] It's not installed yet. [13:05] I'm just saying I didn't mess up the build or choose the wrong place to shove in arguments. [13:05] yea, but just from looking at the command line I can tell [13:07] OK, I've put it in. [13:08] It will fail in all the ways that Yoz fixed, but I think we can work from there. [13:08] which url? [13:08] http://fos.textfiles.com/dfjustin/jaguar/jaguar-workers/ [13:09] yes, as I thought [13:09] it didn't actually work [13:09] we need to add "-g" to emccopts [13:09] instead of DEBUG=1 [13:10] .. " -s TOTAL_MEMORY=268435456" [13:10] .. " -g" [13:10] .. " --proxy-to-worker" [13:10] .. " -s DISABLE_EXCEPTION_CATCHING=2" [13:10] and so on? [13:10] yes [13:10] looks like there's a way to do this without modifying the file though [13:11] Too late this time around, but I'm willing to do that for the future. [13:11] :) [13:12] Boy, I hope this works. [13:13] should make it easier to debug [13:16] emmake make -j16 SYMBOLS=1 SUBTARGET=jaguar SOURCES=src/mame/drivers/jaguar.cpp [13:16] the SYMBOLS=1 makes it add -g to the emcc command [13:17] So replace it with that later [13:18] And -j16? On THIS old thing? [13:20] /0/home/dfjustin/emscripten/emcc -O3 -s USE_SDL=2 -s USE_SDL_TTF=2 --memory-init-file 0 -s ALLOW_MEMORY_GROWTH=0 -s TOTAL_MEMORY=268435456 -g --proxy-to-worker -s DISABLE_EXCEPTION_CATCHING=2 -s EXCEPTION_CATCHING_WHITELIST='["__ZN15running_machine17start_all_devicesEv","__ZN12cli_frontend7executeEiPPc"]' -s EXPORTED_FUNCTIONS="['_main', '_malloc', '__Z14js_get_machinev', '__Z9js_get_uiv', '__Z12js_get_ [13:20] soundv', '__ZN15mame_ui_manager12set_show_fpsEb', '__ZNK15mame_ui_manager8show_fpsEv', '__ZN13sound_manager4muteEbh', '_SDL_PauseAudio', '_SDL_SendKeyboardKey']" --pre-js /0/JSMESS/mame/src/osd/modules/sound/js_sound.js --post-js /0/JSMESS/mame/scripts/resources/emscripten/emscripten_post.js --embed-file /0/JSMESS/mame/bgfx/chains@bgfx/chains --embed-file /0/JSMESS/mame/bgfx/effects@bgfx/effects --embed- [13:20] file /0/JSMESS/mame/bgfx/shaders/gles@bgfx/shaders/gles --embed-file /0/JSMESS/mame/artwork/slot-mask.png@artwork/slot-mask.png ../../../../../jaguar.bc -o /0/JSMESS/mame/mamejaguar.js [13:21] warning: Output contains some very large functions (3680 lines in __ZN10lua_engine10initializeEv), consider building source files with -Os or -Oz, and/or trying OUTLINING_LIMIT to break them up (see settings.js; note that the parameter there affects AST nodes, while we measure lines here, so the two may not match up) [13:22] Dumped in. [13:26] So, I can help here, thanks to Yoz. [13:26] The error it currently gets is: [13:26] window.jsmame_set_mastervolume = jsmame_web_audio.set_mastervolume; [13:29] "aaah, I see the problem - it.s trying to create an easily-accessible global variable called jsmame_set_mastervolume. The way to do that in standard browser JS is to attach it to the window object. But web workers don.t have a window object" [13:30] What Yoz did was have me do: s/window/self/ in mamejaguar.worker.js [13:30] I can do that again, or we can do something else. [13:30] I can also do the line where it adds that header. [13:31] yes, let's do both [13:31] the -g worked [13:33] OK, doing it now. [13:33] Next error: [13:33] (This is going much cleaner.) [13:34] gain_node.gain.value = 1.0; [13:34] TypeError: gain_node.gain is undefined [13:36] root@teamarchive0:/HTML/dfjustin/jaguar/jaguar-workers# head -1 mamejaguar.worker.js [13:36] importScripts("webaudio.js"); [13:36] It's in webaudio.js [13:36] So another websplosion [13:39] So this moves into the edge of my abilities [13:39] I don't know if this is saying it's failing to import webaudio.js or if it's something else. [14:31] I don't really see why this is failing [14:33] So, I am positive it's interaction between the worker and the main thread. [14:33] https://github.com/kripken/emscripten/issues/3566 [14:36] yes, that is [14:36] this gain_node.gain is undefined error is more puzzling [14:37] Should I experiment by prepending all of webaudio.js to it? [14:37] Or is that just insane hackery. [14:38] can you show me the contents of webaudio.js? [14:39] oh: http://fos.textfiles.com/dfjustin/jaguar/jaguar-workers/webaudio.js [14:39] Yes [15:11] well, I can't figure out why it's failing [15:11] but for the moment, you could make a change to it [15:11] where it says gain_node.gain.value = gain_web_audio; [15:14] put if (gain_node.gain) { gain_node.gain.value = gain_web_audio; } instead [15:14] we won't be able to change the volume, but it won't break either [15:16] Change made [15:17] Weird, new break with same issue [15:19] but on a different line [15:20] you can do the same thing there [15:20] remove gain_node.gain.value = 1.0; and put if (gain_node.gain) { gain_node.gain.value = 1.0; } [15:22] Done [15:41] function init_event() { [15:41] if (typeof context.createScriptProcessor == "function") { [15:41] eventNode = context.createScriptProcessor(4096, 0, 2); [15:41] } else if (typeof context.createJavaScriptNode == "function") { [15:41] eventNode = context.createJavaScriptNode(4096, 0, 2); [15:41] } [15:41] if (eventNode) { [15:41] eventNode.onaudioprocess = tick; [15:41] eventNode.connect(gain_node); [15:41] initializeWatchDogForFirefoxBug(); [15:41] } [15:41] } [15:43] So replace it? [15:43] yea [15:46] hahaha [15:46] So.... it worked [15:46] But... [15:46] Well, go look at THAT shit [15:48] :) [15:50] So, this brings to light a lot of the problems in case. [15:51] yea [15:52] it shouldn't be doing the web audio stuff in the worker [15:52] it should proxy that data out to the page the same way it proxies the canvas data out [15:57] Yeah, so there's a fundamental bit there. [15:57] So it's not bringing up Jaguar. [15:58] And I think it's because it's not loading the ROMs [15:59] that makes sense [16:03] I think we need to do what that banana thing is doing [16:03] Prepend some of the loading in the script. [16:03] the worker. [16:35] Want to call it and rope around later? [16:35] Or are you hot on the trail [16:36] I sent this to Alon, see if he gets an idea, too [16:54] I was thinking of adapting the emularity to set up the worker script and whatnot [16:54] but then I got distracted [17:04] I endorse anything [17:05] But I do think that hacking this just enough to get this working to see if it even gives us a real speed increase is key [17:05] You might think otherwise, though [17:08] Like, if it doubles or triples speed because of multi-tasking, great [17:08] Or even 30-40% [17:08] But if it's all this pain for 10% more, it's worth just waiting for the next innovations along Emscripten and Webassembly.