-
Notifications
You must be signed in to change notification settings - Fork 164
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
Incompatible PNG when running on Raspberry Pi (ARMv6) #13
Comments
It's something bad with CRC-32 calculation. |
Could you please test this script https://github.com/alexeyten/qr-image/blob/master/test-crc.js |
also |
|
I think it might have to do with overflow on the ^ bitwise operator - have been working on a good test for it. I'll post when I get something. |
It is at least a problem with overflow in the bitwise XOR operations (^). Building up a longer and longer bit pattern like this:
and running it on X86 ends in:
while running it on ARM yields:
|
Probably you should file bug to node.js I'll think of some kind workaround |
How does other bit operators ( |
I'll try that. If you don't depend on overflowing behavior, I was thinking about trying .xor(n) from https://github.com/substack/node-bigint |
It uses libgmp. I try not to depend on any modules, especially binary ones. I guess, it should be not hard to write workaround using buffers or typed arrays. |
Buffers sounds like a good idea. I can test code for you if you can work on it. If not, I can work on it and build a PR for you but it will take some time - I have to figure out how CRC32 is supposed to work! |
Could you test branch issue-13-crc32 |
test-crc.js returns true now. (!) Testing PNG file creation now... |
Confirmed. PNG creation now works on ARM! Thanks for the quick turn-around. |
Well, now I'd like some simple way to check if platform has buggy xor. Could you provide me some simple expression like |
This is proving to be very difficult. It seems to only happen when after the first iteration inside a loop. I think it might have something to do with optimizations - particularly variable reuse. Still working... This is clearly either a V8 bug or a node.js bug because they are relying on an outdated V8 engine. |
V8 issue logged: |
Ok. Then how to know if it's armv6? Probably some method from |
This will return true if it is ARMv6:
|
OK. I'll look into it on Monday.
|
Thanks for all the help. |
Could you tell, what |
|
It's Should be something
|
Sorry, correct - that was os.cpus(). Here's os.arch():
|
As I learn from https://code.google.com/p/v8/issues/detail?id=3757 bug is in old v8 engine? |
Can you confirm that latest https://github.com/alexeyten/qr-image/commits/issue-13-crc32 works on both arm and x86? I'll merge it then. |
Confirmed - this works now. Thanks for the quick fix. |
Hi, this patch assumes node with global "process" and breaks web use. if (process.arch === 'arm') { like if (process && process.arch === 'arm') { ... |
I'm going to get rid of this patch in new version. It was 4 years and several major versions of node ago, and I hope there is no need for it now. |
When running this on X86 Linux or X86 Mac:
I get good images.
However, when running on a Raspberry Pi (ARMv6) I get an invalid PNG file.
Here's a hex dump of the invalid PNG:
Here's a hex dump of the good PNG:
The header looks good but it goes off the rails around the 00FFFFFF at the end of the top line.
Possibly some sort of big-endian / little-endian issue?
node version: v0.11.11-pre
The text was updated successfully, but these errors were encountered: