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

factor out 'webglcontextlost' listener #38

Open
pixelzoom opened this issue Mar 9, 2017 · 1 comment
Open

factor out 'webglcontextlost' listener #38

pixelzoom opened this issue Mar 9, 2017 · 1 comment
Assignees

Comments

@pixelzoom
Copy link
Contributor

pixelzoom commented Mar 9, 2017

3/9/17 dev meeting:

Molecule Shapes (phetsims/molecule-shapes#147) and Neuron (phetsims/neuron#134) contain duplicate code for handling WebGL context loss.

MoleculeShapes.MoleculeShapesScreenView:

      this.threeRenderer.context.canvas.addEventListener( 'webglcontextlost', function( event ) {
        event.preventDefault();

        self.showContextLossDialog();

        if ( document.domain === 'phet.colorado.edu' ) {
          window._gaq && window._gaq.push( [ '_trackEvent', 'WebGL Context Loss', 'molecule-shapes ' + phet.joist.sim.version, document.URL ] );
        }
      } );

Neuron.ParticlesWebGLNode:

    this.contextLossListener = function( event ) {
      event.preventDefault();

      new ContextLossFailureDialog().show();

      if ( document.domain === 'phet.colorado.edu' ) {
        window._gaq && window._gaq.push( [ '_trackEvent', 'WebGL Context Loss', 'neuron' + phet.joist.sim.version, document.URL ] );
      }
    };

    // set up a handler for context loss - this will just put up a dialog, better handling may exist eventually
    gl.canvas.addEventListener( 'webglcontextlost', this.contextLossListener );

This code should be factored out. @jonathanolson volunteered to handle this, and determine the appropriate place for it.

@pixelzoom
Copy link
Contributor Author

This is also related to phetsims/joist#411. The usage of phet.joist.sim.version should be replaced with whatever abstraction is provided for the version identifier.

@pixelzoom pixelzoom changed the title factor out WebGL context loss code factor out WebGL context loss listener Mar 9, 2017
@pixelzoom pixelzoom changed the title factor out WebGL context loss listener factor out 'webglcontextlost' listener Mar 9, 2017
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