feat: initial support for Safari rendering of images#992
Conversation
There isn’t any safaridriver support for headless mode yet unfortunately.
|
Thanks! Interesting that safari options are so limited. So a Safari window will pop up while se build is rendering? If that's the case then we should probably add code to prefer Firefox/Chrome if they're installed before falling back to Safari. I don't know if |
|
Or, the more I think about it, if we can't get Safari headless and it literally pops up multiple windows while processing an ebook, maybe we should just decline to support Safari for now? It seems like it would be pretty annoying to be running a terminal task and a series of windows pops up randomly. |
|
Also just to be clear, in terms of We also have to confirm that |
|
I was assuming this was just for local test builds, but I guess white label builds might happen in Safari. Either way, if I’m reading the code right, installed_browsers just iterates over a big list of possible browsers it knows about and checks if they’re installed: https://github.com/undeflorate/installed_browsers/blob/master/installed_browsers/mac.py. If a user has Chrome or Firefox installed then Safari won’t be picked. But I guess if they have Brave or Opera and Safari then it’ll go Safari. I’ll add some code to push Safari to the end. Either way, on my M2 Macbook Air, building Nantucket is under half a second of Safari window time. |
This is for the whole toolset - anyone building an ebook that has non-boilerplate SVGs will be affected, since
Yes, but the problem is that I don't know if/how the browsers are ordered. If they're unordered, then Safari might come first and it could return a Safari instance instead of a Firefox instance. I'm still not sure if we should have a window pop up at all... that is very unexpected for a CLI and annoying in any case, because someone could be typing or clicking when it pops up. And the windows might pop up multiple times if there are multiple SVGs to process. If we can't get Safari to work in a headless mode, then let's put this on the back burner for now. I think a popup window is too annoying and we can just ask them to install Firefox/Chrome instead. I assumed headless Safari was possible since so many developers are on Macs, but perhaps not. |
…due to lack of options.
|
OK, up to you. I’ve pushed a commit that moves Safari to the end of the list anyway, so it’ll only run if a user only has Safari and no other browsers installed. |
|
OK, I'll merge it in for now and let me think about it. I might comment it out with a note so if/when Safari can be used in headless mode we can just uncomment the code. |
|
Were you able to confirm that |
|
Ah, right, hadn’t realised that was a thing. I’ll add a fix for that in a separate PR. |
There isn’t any safaridriver support for headless mode yet unfortunately.
This produces reasonable quality images, but I haven’t found any way of setting the rendering DPI or window size yet: everything seems really limited compared to Firefox / Chrome.