<commit_before>var PIXI = require('pixi.js/bin/pixi.dev.js');
var animate = require('app/util/animate');
var trackEvent = require('app/util/trackEvent');
var {Promise} = require('es6-promise');
var backImage = require('url?limit=10000!app/images/back-arrow.png');
var RecordButton = require('app/views/RecordButton');
var zIndexes = require('app/util/zIndexes');
var currentViewportDetails = require('app/util/currentViewportDetails');
var {setHasAntialiasing} = require('app/util/generateTexture');

module.exports = (function() {
  'use strict';

  const MAX_CONTENT_WIDTH = 1024;
  const CONTENT_ASPECT_RATIO_HORIZONTAL = 2 / 1;
  const CONTENT_ASPECT_RATIO_VERTICAL = 2 / 3;
  const CONTENT_HORIZONTAL_BUFFER_DESKTOP = 64;
  const CONTENT_HORIZONTAL_BUFFER_MOBILE = 24;
  const CONTENT_VERTICAL_BUFFER_DESKTOP = 150;
  const CONTENT_VERTICAL_BUFFER_MOBILE = 32;
  const CONTENT_CONTROLS_BUFFER = 80;
  const MOBILE_MAX = 767;

  var isRetina = false;

  var canvasRenderers;
  var webGLRenderers;
  var hasAntialiasing;

  /**
   * WebGL can never clean up after old contexts, so we reuse ours in a pool.
   */
  function buildRendererPool() {
    var antialias = true;

    if (window.navigator.userAgent.match(/Safari/) &&
        window.navigator.userAgent.match(/Version\/8/)) {
      antialias = false;
    }

    canvasRenderers = [];
    webGLRenderers = [];

    for (let i = 0; i < 5; i++) {
      let webGLRenderer = new PIXI.WebGLRenderer(window.innerWidth, window.innerHeight, {
        antialias: antialias,
        transparent: false,
        resolution: 1
      });

      if ('undefined' === typeof hasAntialiasing) {
        let requestedAntialiasing = webGLRenderer.gl.getContextAttributes().antialias;
        let size = webGLRenderer.gl.getParameter(webGLRenderer.gl.SAMPLES);
        hasAntialiasing = requestedAntialiasing && (size > 0);
      }

      webGLRenderers.push(webGLRenderer);
    }

    setHasAntialiasing(hasAntialiasing);

    if (!hasAntialiasing) {
      for (let i = 0; i < 5; i++) {
        let canvasRenderer = new PIXI.CanvasRenderer(window.innerWidth, window.innerHeight, {
          transparent: false,
          resolution: isRetina ? 2 : 1
        });

        if (isRetina) {
          canvasRenderer.view.style.width = `${canvasRenderer.width/2}px`;
          canvasRenderer.view.style.height = `${canvasRenderer.height/2}px`;
        }

        canvasRenderer.updateTexture = function() {};
        canvasRenderers.push(canvasRenderer);
      }
    }
  }

  /**
   * Get a renderer from the pool.
   * @return {PIXI.WebGLRenderer}
   */
  function getRenderer(type) {
    if (type === PIXI.CanvasRenderer) {
      return canvasRenderers.pop();
    } else {
      return webGLRenderers.pop();
    }
  }

  /**
   * Return a renderer to the pool.
   * @param {PIXI.WebGLRenderer} renderer - The no longer used renderer.
   */
  function returnRenderer(renderer) {
    if (renderer instanceof PIXI.CanvasRenderer) {
      canvasRenderers.push(renderer);
    } else {
      webGLRenderers.push(renderer);
    }
  }

  /**
   * A container that wraps a sub instruments.
   * @param {AudioManager} audioManager - The shared audioManager.
   * @param {Element} elementToMimic_ - The element to watch for our dimensions.
   * @param {Element} viewportElement - The root experiment element.
   * @constructor
   */
  return function InstrumentContainer(audioManager, elementToMimic_, viewportElement) {
    var stage, renderer;
    var pid;
<commit_msg>Fix black square in Safari recording button<commit_after>var PIXI = require('pixi.js/bin/pixi.dev.js');
var animate = require('app/util/animate');
var trackEvent = require('app/util/trackEvent');
var {Promise} = require('es6-promise');
var backImage = require('url?limit=10000!app/images/back-arrow.png');
var RecordButton = require('app/views/RecordButton');
var zIndexes = require('app/util/zIndexes');
var currentViewportDetails = require('app/util/currentViewportDetails');
var {setHasAntialiasing} = require('app/util/generateTexture');

module.exports = (function() {
  'use strict';

  const MAX_CONTENT_WIDTH = 1024;
  const CONTENT_ASPECT_RATIO_HORIZONTAL = 2 / 1;
  const CONTENT_ASPECT_RATIO_VERTICAL = 2 / 3;
  const CONTENT_HORIZONTAL_BUFFER_DESKTOP = 64;
  const CONTENT_HORIZONTAL_BUFFER_MOBILE = 24;
  const CONTENT_VERTICAL_BUFFER_DESKTOP = 150;
  const CONTENT_VERTICAL_BUFFER_MOBILE = 32;
  const CONTENT_CONTROLS_BUFFER = 80;
  const MOBILE_MAX = 767;

  var isRetina = false;

  var canvasRenderers;
  var webGLRenderers;
  var hasAntialiasing;

  /**
   * WebGL can never clean up after old contexts, so we reuse ours in a pool.
   */
  function buildRendererPool() {
    var antialias = true;

    if (window.navigator.userAgent.match(/Safari/) &&
        window.navigator.userAgent.match(/Version\/8/)) {
      antialias = false;
    }

    canvasRenderers = [];
    webGLRenderers = [];

    for (let i = 0; i < 5; i++) {
      let webGLRenderer = new PIXI.WebGLRenderer(window.innerWidth, window.innerHeight, {
        antialias: antialias,
        transparent: false,
        resolution: 1
      });

      if ('undefined' === typeof hasAntialiasing) {
        let requestedAntialiasing = webGLRenderer.gl.getContextAttributes().antialias;
        let size = webGLRenderer.gl.getParameter(webGLRenderer.gl.SAMPLES);
        hasAntialiasing = requestedAntialiasing && (size > 0);
      }

      webGLRenderers.push(webGLRenderer);
    }

    setHasAntialiasing(hasAntialiasing);

    if (!hasAntialiasing) {
      for (let i = 0; i < 5; i++) {
        let canvasRenderer = new PIXI.CanvasRenderer(window.innerWidth, window.innerHeight, {
          transparent: false,
          resolution: isRetina ? 2 : 1
        });

        if (isRetina) {
          canvasRenderer.view.style.width = `${canvasRenderer.width/2}px`;
          canvasRenderer.view.style.height = `${canvasRenderer.height/2}px`;
        }

        canvasRenderer.updateTexture = function() {};
        canvasRenderers.push(canvasRenderer);
      }
    }
  }

  /**
   * Get a renderer from the pool.
   * @return {PIXI.WebGLRenderer}
   */
  function getRenderer(type) {
    if (type === PIXI.CanvasRenderer) {
      return canvasRenderers.shift();
    } else {
      return webGLRenderers.shift();
    }
  }

  /**
   * Return a renderer to the pool.
   * @param {PIXI.WebGLRenderer} renderer - The no longer used renderer.
   */
  function returnRenderer(renderer) {
    if (renderer instanceof PIXI.CanvasRenderer) {
      canvasRenderers.unshift(renderer);
    } else {
      webGLRenderers.unshift(renderer);
    }
  }

  /**
   * A container that wraps a sub instruments.
   * @param {AudioManager} audioManager - The shared audioManager.
   * @param {Element} elementToMimic_ - The element to watch for our dimensions.
   * @param {Element} viewportElement - The root experiment element.
   * @constructor
   */
  return function InstrumentContainer(audioManager, elementToMimic_, viewportElement) {
    var stage, renderer;
    var pid;

{'fraction_non_alphanumeric': 0.11426947129050596, 'fraction_numerical': 0.011085844229675953, 'mean_word_length': 3.2162971839424803, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7476418', 'n_tokens_mistral': 2342, 'n_tokens_neox': 2250, 'n_words': 488}