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

fix: immediately render for JavaFX #7502

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading