Hi all,
I don't regularly do these announcements here, but this one fixed a bug that was reported 9 years ago https://github.com/codefrau/SqueakJS/issues/23, and I finally fixed it with the help of Agustin Martinez, who narrowed down the issue to the exact BitBlt call that produced the wrong result.
The issue was in the color mapping code:
function rgbMapPixelflags(sourcePixel, mapperFlags) { var val; val = SHIFT((sourcePixel & cmMaskTable[0]), cmShiftTable[0]); val = val | (SHIFT((sourcePixel & cmMaskTable[1]), cmShiftTable[1])); val = val | (SHIFT((sourcePixel & cmMaskTable[2]), cmShiftTable[2])); return val | (SHIFT((sourcePixel & cmMaskTable[3]), cmShiftTable[3])); }
where SHIFT is
function SHIFT(a, b) { return b < 0 ? (b < -31 ? 0 : a >>> (0-b) ) : (b > 31 ? 0 : a << b); }
This is used for swizzling color components in the PNGReadWriter, but rarely anywhere else so it didn't affect the system otherwise, and wrongly led us to believe that it's a PNG-specific issue.
The problem wasn't even in this code but here:
cmShiftTable = loadColorMapShiftOrMaskFrom(interpreterProxy.fetchPointerofObject(0, cmOop));
with
function loadColorMapShiftOrMaskFrom(mapOop) { if (mapOop.isNil) { return null; } if (typeof mapOop === "number") { interpreterProxy.primitiveFail(); return null; } if (!(interpreterProxy.isWords(mapOop) && (SIZEOF(mapOop) === 4))) { interpreterProxy.primitiveFail(); return null; } return mapOop.words; }
This was auto-generated from the Slang BitBlt code back in 2014. Do you see the problem? This is the fix https://github.com/codefrau/SqueakJS/commit/cefa684b57c3984113b82936f448c54b8a930339. (Instead I could have fixed SHIFT() but this seemed simpler)
Anyways, I thought it was interesting :)
The release also adds object pinning https://github.com/codefrau/SqueakJS/commit/63ad01221e1b96799215b54db129bd15ba7f2fb6 and other things Cuis relied on, as well as supporting keyboard input in ancient Scratch images https://github.com/codefrau/SqueakJS/issues/153.
Vanessa
Very cool!
I'm really happy to see SqueakJS updates and announcements like this on vm-dev, thank you.
Dave
On 2023-11-24 15:11, Vanessa Freudenberg wrote:
Hi all,
I don't regularly do these announcements here, but this one fixed a bug that was reported 9 years ago [1], and I finally fixed it with the help of Agustin Martinez, who narrowed down the issue to the exact BitBlt call that produced the wrong result.
The issue was in the color mapping code:
function rgbMapPixelflags(sourcePixel, mapperFlags) { var val; val = SHIFT((sourcePixel & cmMaskTable[0]), cmShiftTable[0]); val = val | (SHIFT((sourcePixel & cmMaskTable[1]), cmShiftTable[1])); val = val | (SHIFT((sourcePixel & cmMaskTable[2]), cmShiftTable[2])); return val | (SHIFT((sourcePixel & cmMaskTable[3]), cmShiftTable[3])); }
where SHIFT is
function SHIFT(a, b) { return b < 0 ? (b < -31 ? 0 : a >>> (0-b) ) : (b > 31 ? 0 : a << b); } This is used for swizzling color components in the PNGReadWriter, but rarely anywhere else so it didn't affect the system otherwise, and wrongly led us to believe that it's a PNG-specific issue.
The problem wasn't even in this code but here:
cmShiftTable = loadColorMapShiftOrMaskFrom(interpreterProxy.fetchPointerofObject(0, cmOop));
with
function loadColorMapShiftOrMaskFrom(mapOop) { if (mapOop.isNil) { return null; } if (typeof mapOop === "number") { interpreterProxy.primitiveFail(); return null; } if (!(interpreterProxy.isWords(mapOop) && (SIZEOF(mapOop) === 4))) { interpreterProxy.primitiveFail(); return null; } return mapOop.words; } This was auto-generated from the Slang BitBlt code back in 2014. Do you see the problem? This is the fix [2]. (Instead I could have fixed SHIFT() but this seemed simpler)
Anyways, I thought it was interesting :)
The release also adds object pinning [3] and other things Cuis relied on, as well as supporting keyboard input in ancient Scratch images [4].
Vanessa
Links: ------ [1] https://github.com/codefrau/SqueakJS/issues/23 [2] https://github.com/codefrau/SqueakJS/commit/cefa684b57c3984113b82936f448c54b... [3] https://github.com/codefrau/SqueakJS/commit/63ad01221e1b96799215b54db129bd15... [4] https://github.com/codefrau/SqueakJS/issues/153
vm-dev@lists.squeakfoundation.org