Issue: URL Assets restart the browser

Src: https://github.com/Screenly/screenly-ose/issues/1031

I thought we can move something like that to these forums and continue here… just so that users start to move from github to these forums to post…

For example, I was able to reproduce, but then reinstalling javascript-common and uzbl made it start working again… but only temporary, then it started failing with same error… here is the log from when it crashed the screenly-viewer just to have as documentation, subsequent crashes from that site gave same error:

> Feb 22 13:51:47 rp300we python[1449]: Showing asset https://www.gorendezvous.www/BookingWidget/?companyId=108450&classesOnly=1 (webpage)
> Feb 22 13:51:47 rp300we wpa_supplicant[372]: wlan1: Failed to initiate sched scan
> Feb 22 13:51:49 rp300we python[1449]: Viewer crashed.
> Feb 22 13:51:49 rp300we python[1449]: Traceback (most recent call last):
> Feb 22 13:51:49 rp300we python[1449]:   File "/home/pi/screenly/viewer.py", line 475, in <module>
> Feb 22 13:51:49 rp300we python[1449]:     main()
> Feb 22 13:51:49 rp300we python[1449]:   File "/home/pi/screenly/viewer.py", line 470, in main
> Feb 22 13:51:49 rp300we python[1449]:     asset_loop(scheduler)
> Feb 22 13:51:49 rp300we python[1449]:   File "/home/pi/screenly/viewer.py", line 410, in asset_loop
> Feb 22 13:51:49 rp300we python[1449]:     browser_url(uri, cb=lambda b: 'LOAD_FINISH' in b)
> Feb 22 13:51:49 rp300we python[1449]:   File "/home/pi/screenly/viewer.py", line 284, in browser_url
> Feb 22 13:51:49 rp300we python[1449]:     browser_send('uri ' + escaped_url, cb=cb)
> Feb 22 13:51:49 rp300we python[1449]:   File "/home/pi/screenly/viewer.py", line 254, in browser_send
> Feb 22 13:51:49 rp300we python[1449]:     browser_event = browser.next()
> Feb 22 13:51:49 rp300we python[1449]:   File "/usr/local/lib/python2.7/dist-packages/sh.py", line 355, in next
> Feb 22 13:51:49 rp300we python[1449]:     self.wait()
> Feb 22 13:51:49 rp300we python[1449]:   File "/usr/local/lib/python2.7/dist-packages/sh.py", line 295, in wait
> Feb 22 13:51:49 rp300we python[1449]:     self._handle_exit_code(self.process.wait())
> Feb 22 13:51:49 rp300we python[1449]:   File "/usr/local/lib/python2.7/dist-packages/sh.py", line 309, in _handle_exit_code
> Feb 22 13:51:49 rp300we python[1449]:     self.process.stderr
> Feb 22 13:51:49 rp300we python[1449]: SignalException_11:
> Feb 22 13:51:49 rp300we python[1449]:   RAN: '/usr/bin/uzbl-browser --config=- --uri=file:///tmp/screenly_html/black_page.html --print-events'
> Feb 22 13:51:49 rp300we python[1449]:   STDOUT:
> Feb 22 13:51:49 rp300we python[1449]: EVENT [1461] INSTANCE_START 1461
> Feb 22 13:51:49 rp300we python[1449]: EVENT [1461] BUILTINS 'back forward scroll reload reload_ign_cache stop zoom_in zoom_out toggle_zoom_type uri js script toggle_status spawn sync_spawn sync_spa
> Feb 22 13:51:49 rp300we python[1449]: EVENT [1461] VARIABLE_SET status_format str '<b>*@[*@TITLE]*@</b> - *@[*@uri]*@ - <span foreground="#bbb">*@NAME</span>'
> Feb 22 13:51:49 rp300we python[1449]: EVENT [1461] VARIA... (10625 more, please see e.stdout)
> Feb 22 13:51:49 rp300we python[1449]:   STDERR:
> Feb 22 13:51:49 rp300we python[1449]: ** Message: console message: https://www.gorendezvous.www/Scripts/gorendezvous.appointmentBookingWidget.min.js?v=vd7Xf_6cCd-tS5-jq2DlP-bltr0QOdwCzbntzzz6N3Q1 *@
> Feb 22 13:51:49 rp300we python[1449]: ** Message: console message: https://www.gorendezvous.www/Scripts/gorendezvous.appointmentBookingWidget.min.js?v=vd7Xf_6cCd-tS5-jq2DlP-bltr0QOdwCzbntzzz6N3Q1 *@
> Feb 22 13:51:49 rp300we python[1449]: ** Message: console message: https://www.gorendezvous.www/Scripts/gorendezvous.appointmentBookingWidget.min.js?v=vd7Xf_6cCd-tS5-jq2DlP-bltr0
QOdwCzbntzzz6N3Q1 *@
> Feb 22 13:51:49 rp300we python[1449]: ** Message: console message: https://www.gorendezvous.www/Scripts/gorendezvous.appointmentBookingWidget.min.js?v=vd7Xf_6cCd-tS5-jq2DlP-bltr0QOdwCzbntzzz6N3Q1 *@
> Feb 22 13:51:49 rp300we python[1449]: Traceback (most recent call last):

Maybe screenshot also help:

image

I tested with another website, and I got similar error…

This time it seems it is something with unicode encode error…

image

I edited

/usr/lib/python2.7/encodings/utf_8.py

and changed the errors=‘strict’ to ‘ignore’ and ‘replace’, just to test, but keep getting same error with any setting…

reference: Unicode HOWTO — Python 2.7.18 documentation

any thoughts?

Ok nevermind I fixed it but this is supposed to be not good to do:

editing the screenly viewer we set the following:

#encode all utf-8
import sys
reload(sys)
sys.setdefaultencoding('utf8')

Hi ealmonte32!

lambda e: 'FOCUS_LOST' in unicode(e.decode('utf-8'))
Here we check all events of uzbl browser for occurrence of substring.
Since the events include titles and some components of the web page, we catch the error.
Thus I think we need to rewrite this part of the code, and similar. What do you think?

Yes, but I thought catching the error does not solve the issue of viewer crashing, thus we need to use something like:

url = urllib.unquote(url).decode('utf8') 

Others have gotten this to work this way, like some form of the urllib module. I will try tomorrow to run an edited viewer.py to see.
I don’t know that much about which way works best, whether unicode or using urllib because some people say python 2.7 is not as good as python 3 for this, and also whether to encode something instead of decoding… makes my head hurt.

Maybe we can try what user “agf” says on this stackoverflow post which is this exact error, and more than 1,000 people said its good:

https://stackoverflow.com/questions/9942594/unicodeencodeerror-ascii-codec-cant-encode-character-u-xa0-in-position-20

@rusko124

Thanks for implementing the uri decode fix for uzbl, but weirdly, my viewer.py is not running the updated decode and it works fine for all of the urls that were crashing the viewer…

Reference: