Skip to content

factor out 'webglcontextlost' listener #38

@pixelzoom

Description

@pixelzoom

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions