Skip to content

Commit

Permalink
We need these setTimeouts to be on window in Scenery, see phetsims/ph…
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanolson committed Mar 18, 2021
1 parent 0f8fb2c commit 2ba791c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion js/display/WebGLBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ class WebGLBlock extends FittedBlock {
const self = this;

// TODO: Can we move this to before the update() step? Could happen same-frame in that case.
window.setTimeout( function() {
// NOTE: We don't want to rely on a common timer, so we're using the built-in form on purpose.
window.setTimeout( function() { // eslint-disable-line bad-sim-text
sceneryLog && sceneryLog.WebGLBlock && sceneryLog.WebGLBlock( `Executing delayed rebuilding #${this.id}` );
sceneryLog && sceneryLog.WebGLBlock && sceneryLog.push();
self.rebuildCanvas();
Expand Down
6 changes: 4 additions & 2 deletions js/util/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ const Utils = {
window.requestAnimationFrame = callback => {
const timeAtStart = Date.now();

return window.setTimeout( () => {
// NOTE: We don't want to rely on a common timer, so we're using the built-in form on purpose.
return window.setTimeout( () => { // eslint-disable-line bad-sim-text
callback( Date.now() - timeAtStart );
}, 16 );
};
Expand Down Expand Up @@ -589,7 +590,8 @@ const Utils = {
if ( extension ) {
extension.loseContext();

setTimeout( () => {
// NOTE: We don't want to rely on a common timer, so we're using the built-in form on purpose.
setTimeout( () => { // eslint-disable-line bad-sim-text
extension.restoreContext();
}, 1000 );
}
Expand Down

0 comments on commit 2ba791c

Please sign in to comment.