I have a liveview which needs to be printable from the browser, but it is finicky in that it often will not let me print. When I open the print module (cmd + p or via the file menu), the print window opens but crashes without fully loading after a few seconds. The browser window itself does not crash, however. I’ve noticed that if I try to print immediately after loading the view, it seems to work. But if I use any of the phx-clicks in the view, it will no longer print.
I have not seen the “print window crash” but I know (at least earlier this year) on windows x chrome, the print dialog would suspend network traffic or the JS engine and the LV would disconnect, so you need to have any reconnect-recovery code sorted out.
Do you mean the actual OS “pick your printer and paper size” window … automatically closes? Shows an error message? I guess you are on macOS by the cmd-p language.
I have never had issues printing a LV (~0.18, 0.19?, not tested 0.20 in production) and some of my applications print lots of things different views.
I wonder if your “print immediately” is printing before the websocket connects? I would at least try printing with the connection disabled to see if its some quirk there. Does the behaviour change when you navigate to the page when already connected, vs refreshing it?
Hi Soup,
Thank you very much for the assist. I’m sorry for the delayed reply… we’ve been through it the past month and this fell out of mind.
Correct, I hit cmd+p to print and the OS print dialogue starts to open but disappears. There is no error message. I can print this elixirforum page just fine with this method. But on my app the print window disappears while trying to load.
I definitely do not have lv reconnnect-recovery code sorted. So I’ll focus there to start. I’ve read about that in the past and did not feel like I understood or handled. If you know of a good ref and can point me to it, much appreciated.
I upgraded my LV from 0.17 to 0.18.18 and phx to 1.7 and the print problem is now resolved.
Thank you for taking a look at it and the direction. Researching methods for handling disconnections in LV prompted me to upgrade LV and I’m still planning to implement the rest of the strategy despite the print bug fix. Thank you