Skip to content

Commit

Permalink
fix: immediately render for JavaFX (#7502)
Browse files Browse the repository at this point in the history
  • Loading branch information
BeksOmega authored Sep 18, 2023
1 parent c3b7d42 commit f8a134c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions core/render_management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import {BlockSvg} from './block_svg.js';
import {Coordinate} from './utils/coordinate.js';
import * as userAgent from './utils/useragent.js';

/** The set of all blocks in need of rendering which don't have parents. */
const rootBlocks = new Set<BlockSvg>();
Expand Down Expand Up @@ -42,6 +43,12 @@ let animationRequestId = 0;
*/
export function queueRender(block: BlockSvg): Promise<void> {
queueBlock(block);

if (alwaysImmediatelyRender()) {
doRenders();
return Promise.resolve();
}

if (!afterRendersPromise) {
afterRendersPromise = new Promise((resolve) => {
afterRendersResolver = resolve;
Expand Down Expand Up @@ -77,6 +84,15 @@ export function triggerQueuedRenders() {
if (afterRendersResolver) afterRendersResolver();
}

/**
* @returns True if we should always trigger an immediate render.
* Some platforms don't properly support `requestAnimationFrame`, so to
* avoid glitchiness, we give up the performance improvements.
*/
function alwaysImmediatelyRender() {
return userAgent.JavaFx;
}

/**
* Adds the given block and its parents to the render queue. Adds the root block
* to the list of root blocks.
Expand Down

0 comments on commit f8a134c

Please sign in to comment.