scottpchow23 / runekit

Alt1-compatible widget host for RuneScape 3
GNU General Public License v3.0
2 stars 0 forks source link

Doesn't capture when game is full screen on second monitor(Mac) #3

Open scottpchow23 opened 3 years ago

scottpchow23 commented 3 years ago

Steps to reproduce:

image

Here's the entire stack trace:

INFO:root:Starting QtWebEngine
INFO:root:Scanning for game instances
INFO:root:Found 2 instances
INFO:root:Loading app
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): runeapps.org:443
DEBUG:urllib3.connectionpool:https://runeapps.org:443 "GET /apps/clue/appconfig.json HTTP/1.1" 200 655
Traceback (most recent call last):
  File "/Users/scottpchow/GitHub/runekit/main.py", line 86, in <module>
    main()
  File "/Users/scottpchow/Library/Caches/pypoetry/virtualenvs/runekit-7PlzRDS0-py3.9/lib/python3.9/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/Users/scottpchow/Library/Caches/pypoetry/virtualenvs/runekit-7PlzRDS0-py3.9/lib/python3.9/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/Users/scottpchow/Library/Caches/pypoetry/virtualenvs/runekit-7PlzRDS0-py3.9/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/scottpchow/Library/Caches/pypoetry/virtualenvs/runekit-7PlzRDS0-py3.9/lib/python3.9/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Users/scottpchow/GitHub/runekit/main.py", line 66, in main
    host.start_app(app_url, game)
  File "/Users/scottpchow/GitHub/runekit/runekit/host/host.py", line 29, in start_app
    app.get_window(parent=self).show()
  File "/Users/scottpchow/GitHub/runekit/runekit/app/app.py", line 29, in get_window
    self.window = AppWindow(app=self, **kwargs)
  File "/Users/scottpchow/GitHub/runekit/runekit/app/view/window.py", line 26, in __init__
    super().__init__(flags=flags, **kwargs)
  File "/Users/scottpchow/GitHub/runekit/runekit/app/view/browser_window.py", line 29, in __init__
    self._setup_browser()
  File "/Users/scottpchow/GitHub/runekit/runekit/app/view/browser_window.py", line 41, in _setup_browser
    page = QWebEnginePage(self.app.get_web_profile(), self.browser)
  File "/Users/scottpchow/GitHub/runekit/runekit/app/app.py", line 49, in get_web_profile
    self.web_profile = WebProfile(app=self, parent=self.window)
  File "/Users/scottpchow/GitHub/runekit/runekit/browser/profile.py", line 32, in __init__
    self._insert_scheme_handlers()
  File "/Users/scottpchow/GitHub/runekit/runekit/browser/profile.py", line 40, in _insert_scheme_handlers
    api=self.app.get_api(),
  File "/Users/scottpchow/GitHub/runekit/runekit/app/app.py", line 38, in get_api
    self.alt1api = Alt1Api(app=self, parent=self.window)
  File "/Users/scottpchow/GitHub/runekit/runekit/browser/api.py", line 92, in __init__
    self._game_scaling = self.app.game_instance.get_scaling()
  File "/Users/scottpchow/GitHub/runekit/runekit/game/quartz/instance.py", line 140, in get_scaling
    return screen.devicePixelRatio()
AttributeError: 'NoneType' object has no attribute 'devicePixelRatio'

Workaround:

scottpchow23 commented 3 years ago

Issue seems to tie back to an error when invoking the QGuiApplication.screenAt(...) in runekit/game/quartz/instance.py:

    def get_scaling(self) -> float:
        # screen ends up as nil
        screen = QGuiApplication.screenAt(self.get_position().topLeft())
        return screen.devicePixelRatio()
scottpchow23 commented 3 years ago

Apparently that's part of the issue. If I hardcode the above to give the correct monitor/scaling, the app doesn't work (likely because the screenshots are bad).