Workaround

Two weeks ago, I wrote:

I woke up today to a very annoying new bug in Firefox. The browser shits the bed in an unpredictable fashion when rounding up single pixel line widths in SVG. That’s quite a problem on The Session where all the sheet music…


This content originally appeared on Adactio: Journal and was authored by Adactio: Journal

Two weeks ago, I wrote:

I woke up today to a very annoying new bug in Firefox. The browser shits the bed in an unpredictable fashion when rounding up single pixel line widths in SVG. That’s quite a problem on The Session where all the sheet music is rendered in SVG. Those thin lines in sheet music are kind of important.

Paul Rosen, who makes abcjs, the JavaScript library that renders sheet music on The Session, managed to get a fix out pretty quickly. But I use an older version of the library and updating it would introduce some side-effects that would take me a while to work around. So that option wasn’t available to me.

In this situation, when the problem is caused by a browser bug, the correct course of action is to file a bug with the browser. That had already been done. Now all I could do was twiddle my thumbs and wait for the next release of the browser, which would hopefully ship with the fix.

But I figured I may as well try to find a temporary workaround in the meantime.

At first, I looked at diving into the internals of the JavaScript—that’s where the instructions are given for drawing the SVGs.

But then I stopped and thought, “If the problem is with the rendering of the SVG, maybe CSS can help.”

I started messing around with SVG-specific CSS properties like stroke, fill, and so on. With dev tools open, I started targeting the paths that acted as bar lines in the sheet music, playing around with widths, opacities, and fills.

It was the debugging equivalent of throwing spaghetti at the wall. Remarkably, it actually worked.

I found a solution with this nonsensical bit of CSS:

stroke: currentColor;
stroke-opacity: 0;

For some reason, rather than making all the barlines disappear, this ensured they were visible.

It’s the worst kind of hacky fix—the kind where you have no idea why it works, but it does.

So I shipped it.

And at pretty much exactly the same time, a new version of Firefox dropped …with the bug fixed.

I can’t deny that there was a certain satisfaction in being able to work around a browser bug. But there’s much more satisfaction in deleting the hacky workaround when it’s no longer needed.


This content originally appeared on Adactio: Journal and was authored by Adactio: Journal


Print Share Comment Cite Upload Translate Updates
APA

Adactio: Journal | Sciencx (2023-04-26T09:39:30+00:00) Workaround. Retrieved from https://www.scien.cx/2023/04/26/workaround/

MLA
" » Workaround." Adactio: Journal | Sciencx - Wednesday April 26, 2023, https://www.scien.cx/2023/04/26/workaround/
HARVARD
Adactio: Journal | Sciencx Wednesday April 26, 2023 » Workaround., viewed ,<https://www.scien.cx/2023/04/26/workaround/>
VANCOUVER
Adactio: Journal | Sciencx - » Workaround. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/04/26/workaround/
CHICAGO
" » Workaround." Adactio: Journal | Sciencx - Accessed . https://www.scien.cx/2023/04/26/workaround/
IEEE
" » Workaround." Adactio: Journal | Sciencx [Online]. Available: https://www.scien.cx/2023/04/26/workaround/. [Accessed: ]
rf:citation
» Workaround | Adactio: Journal | Sciencx | https://www.scien.cx/2023/04/26/workaround/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.