Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: fix chromium screenshots issues with CDP #955

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ RUN pip3 install /app
ENV PYTHONPATH $PYTHONPATH:/app
#ENV QT_DEBUG_PLUGINS=1

# Enable Chrome DevTools Protocol (CDP) in QtWebEngine
ENV QTWEBENGINE_REMOTE_DEBUGGING "127.0.0.1:9050"

# Chromium refuses to start under root
RUN groupadd -r splash && useradd --no-log-init --create-home -r -g splash splash
RUN chown -R splash:splash /app
Expand Down
4 changes: 2 additions & 2 deletions dockerfiles/splash/install-python-splash-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ install_python_deps () {
# Install python-level dependencies.
${_PYTHON} -m pip install -U pip setuptools six && \
${_PYTHON} -m pip install \
qt5reactor==0.5 \
asyncqt==0.7.0 \
psutil==5.0.0 \
"Twisted[http2]==19.7.0" \
adblockparser==0.7 \
Expand All @@ -17,4 +17,4 @@ install_python_deps () {
${_PYTHON} -m pip install https://github.com/sunu/pyre2/archive/c610be52c3b5379b257d56fc0669d022fd70082a.zip#egg=re2
}

install_python_deps
install_python_deps
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# install PyQt5 (Splash is tested on PyQT 5.13)
# and the following packages:
twisted[http2] == 19.7.0
qt5reactor
asyncqt == 0.7.0
psutil
adblockparser >= 0.5
https://github.com/sunu/pyre2/archive/c610be52c3b5379b257d56fc0669d022fd70082a.zip#egg=re2
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def get_version():
'zip_safe': False,
'install_requires': [
'Twisted[http2] >= 19.7.0',
'qt5reactor',
'asyncqt',
'psutil',
'adblockparser',
'xvfbwrapper',
Expand Down
3 changes: 3 additions & 0 deletions splash/qtutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ def awake(self):
diff = time.time() - self.blockedAt
log.msg("awake; block time: %0.4f" % diff, system="QAbstractEventDispatcher")
_qtapp = QApp(sys.argv)
# we have to set this, because otherwise the program may quit when
# the last web view window is closed.
_qtapp.setQuitOnLastWindowClosed(False)
return _qtapp


Expand Down
16 changes: 12 additions & 4 deletions splash/server.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
import os
import sys
import optparse
Expand All @@ -7,6 +8,9 @@
import functools
import faulthandler

from asyncqt import QEventLoop
from twisted.internet import asyncioreactor

from splash import defaults, __version__
from splash import xvfb
from splash.qtutils import init_qt_app
Expand All @@ -15,10 +19,14 @@


def install_qtreactor(verbose):
init_qt_app(verbose)
import qt5reactor
qt5reactor.install()

"""
Install asyncqt eventloop for asyncio, and then install the
asyncioreactor for twisted.
"""
qtapp = init_qt_app(verbose)
loop = QEventLoop(qtapp)
asyncio.set_event_loop(loop)
asyncioreactor.install(loop)

def parse_opts(jupyter=False, argv=None):
if argv is None:
Expand Down