choojs / nanotiming

⏲ - Small timing library
MIT License
35 stars 11 forks source link

Consecutive measurements in fast order causes Safari 11 to crash #13

Closed tornqvist closed 7 years ago

tornqvist commented 7 years ago

We have a suboptimal situation where (using choo) we are rerendering a bunch of times in a row due to cached network request finishing at the same time. Safari 11 then throws a SyntaxError.

SyntaxError (DOM Exception 12): The string did not match the expected pattern

I have traced it to perf.measure and suspect it's that there's a conflict with the timestamps. Maybe Safari isn't precise enough in generating them? Anyway, it's really hard to debug because just adding a console.log will circumvent the issue. I guess logging is slowing down the execution enough to generate a unique timestamp in-between calls, but I'm not sure.

I probably should batch the network requests and issue a single render when done but figured I'd just post this here in case someone with a better understanding of the performance api would like to know there's a potential issue with Safari 11.

yoshuawuyts commented 7 years ago

This is a really good catch; I thought we were already try…catching around this, just in case browser bugs exist. If that's not the case, we should definitely add that!

tornqvist commented 7 years ago

Just realized we might want to change the callback signature to also handle the error now that that's a scenario. Though that'd def be a major change.

yoshuawuyts commented 7 years ago

Yeah, good point — I like the changes you've made; think they're good! We can add them to most of our modules with pushing their respective semver major, which is pretty great! :D

yoshuawuyts commented 7 years ago

Fixed in 7.0.0 :tada: