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

WebGL never enabled? #8

Closed
akaihola opened this issue Jun 9, 2016 · 4 comments
Closed

WebGL never enabled? #8

akaihola opened this issue Jun 9, 2016 · 4 comments

Comments

@akaihola
Copy link

akaihola commented Jun 9, 2016

In the WebScreensaver class, you have:

    def setup_browser(self):
        '''Sets up WebKit in our window'''
        self.browser = WebKit.WebView()

        # Try to enable webgl
        try:
            settings = browser.get_settings()
            settings.set_property('enable-webgl', True)
        except:
            pass

On the fourth last line, settings = browser.get_settings() refers to the identifier browser which is never imported or defined. As a result, you always get an exception which is silently caught. This should probably be settings = self.browser.get_settings() instead.

lmartinking pushed a commit that referenced this issue Jun 9, 2016
@lmartinking
Copy link
Owner

Hi @akaihola , thanks for the report!

I believe I've fixed it now on master. Care to give it a try?

@akaihola
Copy link
Author

Well, I didn't actually try to enable WebGL, I just happened to notice this looking at the source code. It now looks correct to me.

Although unless you expect self.browser.get_settings() to fail in normal operation, you should probably move that before the try: block.

Also, using logging instead of print statements would enable you to easily print out the exception, too:

logging.exception('Could not enable WebGL')

@lmartinking
Copy link
Owner

Hi @akaihola, I recall if a setting didn't exist, or could not be set, then an exception was thrown.

I'm not against using logging per se, but as a single script rather than a full on application, print is simpler.

@lmartinking
Copy link
Owner

(Closing due to issue being 3 years old)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants