Performance optimization: Prevent pixi from rendering if any dialog is opened (#4415)

This commit is contained in:
AlexandreS
2022-10-21 15:01:04 +02:00
committed by GitHub
parent 3fc57c2b06
commit 2360cf899f
4 changed files with 13 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
// @flow
export const aboveMaterialUiMaxZIndex = 1501; // highest z-index used by MaterialUI is 1500
import { aboveMaterialUiMaxZIndex } from '../UI/MaterialUISpecificUtil';
const getStyleAttribute = (element: Element, prop: string) =>
getComputedStyle(element).getPropertyValue(prop);

View File

@@ -3,14 +3,11 @@ import * as React from 'react';
import Rectangle from '../Utils/Rectangle';
import useOnResize from '../Utils/UseOnResize';
import useForceUpdate from '../Utils/UseForceUpdate';
import {
aboveMaterialUiMaxZIndex,
getDisplayZIndexForHighlighter,
getScrollParent,
} from './HTMLUtils';
import { getDisplayZIndexForHighlighter, getScrollParent } from './HTMLUtils';
import ArrowTop from '../UI/CustomSvgIcons/ArrowTop';
import ArrowBottom from '../UI/CustomSvgIcons/ArrowBottom';
import useIsElementVisibleInScroll from '../Utils/UseIsElementVisibleInScroll';
import { aboveMaterialUiMaxZIndex } from '../UI/MaterialUISpecificUtil';
type Props = {|
element: HTMLElement,

View File

@@ -32,6 +32,7 @@ import InstancesSelection from './InstancesSelection';
import LongTouchHandler from './LongTouchHandler';
import { type InstancesEditorSettings } from './InstancesEditorSettings';
import Rectangle from '../Utils/Rectangle';
import { isNoDialogOpened } from '../UI/MaterialUISpecificUtil';
const gd: libGDevelop = global.gd;
const styles = {
@@ -926,7 +927,7 @@ export default class InstancesEditor extends Component<Props> {
if (this._renderingPaused) return;
// Avoid killing the CPU by limiting the rendering calls.
if (this.fpsLimiter.shouldUpdate()) {
if (this.fpsLimiter.shouldUpdate() && isNoDialogOpened()) {
this.backgroundColor.render();
this.viewPosition.render();
this.canvasCursor.render();

View File

@@ -0,0 +1,8 @@
// @flow
export const aboveMaterialUiMaxZIndex = 1501; // highest z-index used by MaterialUI is 1500
export const isNoDialogOpened = (): boolean => {
return !document.querySelector(
'body > div[role="presentation"].MuiDialog-root'
);
};