Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in ClientEngine - handleInboundMessage/Serializer.deserialize #103

Open
dev-zetta opened this issue Nov 27, 2018 · 1 comment
Open

Comments

@dev-zetta
Copy link
Contributor

dev-zetta commented Nov 27, 2018

There is a bug in method handleInboundMessage in ClientEngine.

/media/maxli/Data/dev/OpenArcanum/node_modules/lance-gg/es5/serialize/Serializer.js:98 Uncaught TypeError: First argument to DataView constructor must be an ArrayBuffer
    at new DataView (<anonymous>)
    at Serializer.deserialize (/media/maxli/Data/dev/OpenArcanum/node_modules/lance-gg/es5/serialize/Serializer.js:98)
    at NetworkTransmitter.deserializePayload (/media/maxli/Data/dev/OpenArcanum/node_modules/lance-gg/es5/network/NetworkTransmitter.js:111)
    at Client.handleInboundMessage (/media/maxli/Data/dev/OpenArcanum/node_modules/lance-gg/es5/ClientEngine.js:448)
    at Client.handleInboundMessage (Client.js:170)
    at Client.step (/media/maxli/Data/dev/OpenArcanum/node_modules/lance-gg/es5/ClientEngine.js:339)
    at Renderer.runClientStep (/media/maxli/Data/dev/OpenArcanum/node_modules/lance-gg/es5/render/Renderer.js:144)
    at Renderer.draw (/media/maxli/Data/dev/OpenArcanum/node_modules/lance-gg/es5/render/Renderer.js:99)
    at Renderer.draw (Renderer.js:27)
    at renderLoop (/media/maxli/Data/dev/OpenArcanum/node_modules/lance-gg/es5/ClientEngine.js:220)

The DataView expects a ArrayBuffer, but plain Buffer is passed in constructor. The workaround is to override handleInboundMessage in ClientEngine and convert the buffer to ArrayBuffer :

  handleInboundMessage(syncData) {
    let buffer = Uint8Array.from(syncData.dataBuffer)
    syncData.dataBuffer = buffer.buffer
    super.handleInboundMessage(syncData)
  }

This works. However is quite inefficient IMHO. Any chance to fix this any soon?
Running in Electron 3.X.

@namel
Copy link
Member

namel commented Nov 28, 2018

From the code, it seems that the server sends an ArrayBuffer. See

dataBuffer = new ArrayBuffer(bufferSize);

Maybe socket.io changed the data type, or this is an electron issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants