Page 21 - HRM-00-v1
P. 21

 STORY TIME
 The Plight of Open Source
   It was now my job to kick this into production. I estimated it would take me one to two days to run some before and after benchmarks, write some unit tests, and make sure it worked in all browsers. Ev- erything was going well in my initial testing. I could see there was no- ticeably less camera stuttering in specific situations, and the Chrome profiler showed a higher average frame rate than before!
function blobToImageBitmap(blob) {
// https://bugzilla.mozilla.org/show_bug.cgi?id=1335594 return FeatureDetection.isFirefox()
? createImageBitmap(blob)
: createImageBitmap(blob, {
imageOrientation: ‘flipY’
});
}
Code snippet from the original ImageBitmap PR which would flip the image vertically when not using Firefox.
MDN link for ImageBitmap 3.
It was a little peculiar that this flag was set to flip only when it doesn’t detect Firefox (which just meant Chrome, since they were the only two that supported ImageBitmap). The Bugzilla page linked in the code just said that Firefox doesn’t support this flip option. Given that everything was displaying correctly in Firefox, this seemed like a really easy fix. If we didn’t want images to be upside down, then we shouldn’t be flipping them upside down when decoding them!
Even though it was clear that Puckey had used that flag intentionally, it seemed worth a shot. I removed it, and at first glance, everything seemed correct! This seemed too good to be true. I couldn’t see what was wrong until I zoomed out a bit.
Removing the flipY option fixed the models, but something else seemed off.
I was very excited to see the great promise of open source playing out: we had shared our code with the world, and the world was sharing in the burden of developing it.
There was just one tiny problem: all 3D models in the engine now had upside-down textures.
Airplane model in CesiumJS, before implementing ImageBitmap (left) and after (right).
Racing Bicycle model with upside down textures in CesiumJS after implementing ImageBitmap. Model by Francesco Coldesina 2.
I could tell Puckey’s use case did not involve 3D models (contrary to ours, where a large part of our business is a cloud platform for hosting and tiling massive 3D models that users could then view in Cesium- JS).
At this point, I still held strongly to my faith in this valuable contri- bution. Sure, there was one small oversight here, but it was my job as a reviewer to catch this sort of thing. Everything else was working great. Maybe Puckey just missed something obvious, like some “flip all images upside down” flag that was accidentally set.
To my delight, I did actually find exactly such a flag, right in one of the helper functions in the PR!
           September 2019 | 21
 











































































   19   20   21   22   23