emularity icon indicating copy to clipboard operation
emularity copied to clipboard

Uncaught TypeError: Cannot read property 'timestamp' of null

Open dnelband opened this issue 9 years ago • 11 comments

i'd followed all the steps mentioned in dosbox-example.html, but now im getting this error: dosbox-sync.js:1 Uncaught TypeError: Cannot read property 'timestamp' of null at Object.fillGamepadEventData (dosbox-sync.js:1) at _emscripten_get_gamepad_status (dosbox-sync.js:1) at X5 (dosbox-sync.js:6) at qwa (dosbox-sync.js:16) at JH (dosbox-sync.js:9) at ji (dosbox-sync.js:17) at Object.kj [as _main] (dosbox-sync.js:8) at Object.callMain (dosbox-sync.js:24) at doRun (dosbox-sync.js:24) at run (dosbox-sync.js:24)

how can i fix this?

dnelband avatar Jan 09 '17 07:01 dnelband

Neat! I've not seen this error before. It looks like dosbox is trying to read the state of the gamepads, and failing. Is this happening with or without gamepads plugged in? If it's happening with gamepads plugged in and available to JS, can you try running it without them?

Of course this gamepad code is actually coming from Emscripten, so possibly by recompiling DosBox we would get a fix for this problem.

db48x avatar Jan 09 '17 17:01 db48x

hi, thank you for a quick reply and sorry it took me time to answer: no, i dont have any gamepad plugged in. this is the outcome i get following the instructions in example-dosbox.html. how do i recompile?

dnelband avatar Jan 13 '17 09:01 dnelband

FWIW - I have this exact error running example-dosbox.html on the latest Chrome, but it works perfectly fine on Firefox. I have no gamepads plugged in either. I am planning to submit some code the Internet Archive but I figured I'd try to get it running with Emularity first.

palazzol avatar Feb 11 '17 19:02 palazzol

I built my own em-DOSbox and this problem is gone. How can I tell which version of emulator is bundled with Emularity? I'm not sure if there is a build date to look at, because they git annex links.

palazzol avatar Feb 12 '17 17:02 palazzol

Congrats; compiling the emulators is not so easy.

I don't know off-hand if there's a version number or timestamp embedded in the compiled emulator. The git-annex links point to archive.org, where this work originated. It doesn't look like they've updated dosbox since 2015, so it's kinda old now. If this same bug is happening in the games on archive.org then we should fix that.

db48x avatar Feb 17 '17 23:02 db48x

This is caused by a change to what navigator.getGamepads() returns as of Chrome 56. It used to return something like this:

GamepadList {0: undefined, 1: undefined, 2: undefined, 3: undefined, length: 4}

but now it returns

GamepadList {0: null, 1: null, 2: null, 3: null, length: 4}

Emscripten was then checking to see if typeof gamepad[i] == 'undefined', so this change ended up causing the whole thing to break.

Recompiling with a newer Emscripten is the best answer here. There's another hacky short-term option if recompiling isn't an option though, you can just put this up at the top of the loader before it pulls in the game files:

navigator.getGamepads_ = navigator.getGamepads;
navigator.getGamepads = function() {
  var gamepadlist = navigator.getGamepads_();
  var pads = [];
  for (var i = 0; i < gamepadlist.length; i++) {
    pads[i] = (gamepadlist[i] !== null ? gamepadlist[i] : undefined);
  }
  return pads;
}

jbaicoianu avatar Mar 01 '17 02:03 jbaicoianu

Hah. Great find; we'll need to recompile it for archive.org. In the mean time it's a good workaround.

db48x avatar Mar 03 '17 13:03 db48x

Awesome! It looks new .js files have been updated on archive.org, based on the datestamps here: http://archive.org/download/emularity_engine_v1/ But the archive object here is still from 2015: https://archive.org/details/emularity_engine_emdosbox I'm not sure if that is supposed to be updated/superceded with a new upload. Which one do the git-annex links point to, and are they automatically updated?

palazzol avatar Mar 03 '17 15:03 palazzol

Actually, I also found this one as well, which is 2016, and I think it used to match the first URL above. https://archive.org/details/emularity_engine_v1 But maybe not after this fix?

palazzol avatar Mar 03 '17 18:03 palazzol

Yes, it looks like the last time the emulators were rebuilt on archive.org, they went into a different directory, and the old ones are still kicking around. I've updated the links in git-annex; you can check them with git annex whereis.

db48x avatar Mar 05 '17 10:03 db48x

Oh, also; http://archive.org/download/emularity_engine_v1/ and https://archive.org/details/emularity_engine_v1 are the same item. The first url is just the download page for the item, while the second is the main page for it.

db48x avatar Mar 05 '17 10:03 db48x