Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

browser examples do not work with latest build? #83

Closed
mbec-lbto opened this issue May 8, 2019 · 4 comments
Closed

browser examples do not work with latest build? #83

mbec-lbto opened this issue May 8, 2019 · 4 comments

Comments

@mbec-lbto
Copy link
Contributor

mbec-lbto commented May 8, 2019

example/uncompress.html produces

Error: Invalid stream descriptor checksum @6

[edited out irrelevant compress.html output]

@mbec-lbto
Copy link
Contributor Author

Here's another example that might provides additional insights:

<script type="text/javascript">

  var Buffer = require('buffer').Buffer
  var lz4 = require('lz4')

  var data = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'
  data += data


  const inp = new Buffer(data)
  console.log("inp", inp.toString('hex'))

  const enc = lz4.encode(inp)
  console.log( "enc", enc.toString('hex' ))

  const dec = lz4.decode(enc)
  console.log( "dec", dec.toString('hex' ) )

</script>

produces:

inp 4c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e7365637465747572206164697069736963696e6720656c69742c2073656420646f20656975736d6f642074656d706f7220696e6369646964756e74207574206c61626f726520657420646f6c6f7265206d61676e6120616c697175612e4c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e7365637465747572206164697069736963696e6720656c69742c2073656420646f20656975736d6f642074656d706f7220696e6369646964756e74207574206c61626f726520657420646f6c6f7265206d61676e6120616c697175612e

enc
64704d180000808c00000072656d20697073756d20646f6c6f722073697420616d65742c20636f6e7365637465747572206164697069736963696e6720656c69742c2073656420646f20656975736d6f642074656d706f7220696e6369646964756e74207574206c61626f72652065745c00ff0065206d61676e6120616c697175612e7c005dc061676e6120616c697175612e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007c9767e3

Invalid magic number: 184D7064

magic expected value is 184D2204

@mbec-lbto
Copy link
Contributor Author

mbec-lbto commented May 9, 2019

Going down the rabbit hole, there is an issue with Buffer.prototype.slice - that does not slice.

In chrome debugger:

	output.writeInt32LE(lz4_static.MAGICNUMBER, 0, true)

	this.state = STATES.DESCRIPTOR
	var descriptor = output.slice(SIZES.MAGIC, output.length - 1)

descriptor shows as Uint8Array(7) [4, 34, 77, 24, 0, 0, 0 ...

when it should really be Uint8Array(2) [0, 0, ...
and naturally, things start going bad from there

@mbec-lbto
Copy link
Contributor Author

  • buffer@5.2.1 seems to work, yea!
  • unfortunatly, browserify@9.0.8 brings buffer@3.6.0 - that seems broken on modern browsers
  • building lz4.js with the right combination can be done, but messy
  • upgrade to current browserify@16.2.3 breaks the browserification - looking into this next ...

@mbec-lbto mbec-lbto mentioned this issue May 12, 2019
@pierrec
Copy link
Owner

pierrec commented May 13, 2019

Thanks a lot for looking into this.

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

No branches or pull requests

2 participants