question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] Masks performance and HiDPI displays

See original GitHub issue

Hello,

I’ve only just started experimenting with heavy masking in PixiJS and I’ve hit a performance wall when using certain configurations. Specifically, my scene can’t seem to be rendered faster than 30fps in Safari when using the Intel Iris integrated GPUs. I’m using PixiJS 4.3.5.

Here’s a boiled-down snippet of what I’m doing for the moment:

var app = new PIXI.Application(width, height, config);

var mainStage = new PIXI.Container();
var maskStage = new PIXI.Container();

var baseMaskTexture = new PIXI.BaseRenderTexture(width, height, PIXI.SCALE_MODES.LINEAR, 1);
var maskTexture = new PIXI.RenderTexture(baseMaskTexture);
var maskSprite = new PIXI.Sprite(maskTexture);

mainStage.mask = maskSprite;
app.stage.addChild(mainStage);

/* I then add about a dozen Graphics() elements to the maskStage that are later animated
through their .x, .y and .scale props. The mainStage also contains a few Graphics(). */

var img = new PIXI.Sprite.fromImage(someJPEG);
mainStage.addChild(img);


app.ticker.add(function() {
    app.renderer.render(maskStage, maskTexture);
});

As PixiJS only supports Graphics and Sprites as masks at the moment, and I need my main stage to be masked by multiple individual shapes, I placed these shapes into their own container that is rendered into a texture, and that texture is used as the actual mask.

Everything is buttery smooth in Chrome and Firefox (iGPU or dGPU) and Safari (dGPU), but it all becomes super janky in Safari (iGPU). The scene itself is rendered @1.5x on retina displays to avoid as much blurriness as possible but still maintain decent performances. I guess I could go lower than @1.5x in Safari, but I’d rather avoid that.

Now as I said, I’m quite new to masking in PixiJS, so I’m not sure what could be improved (if anything), or if I should or shouldn’t be doing something. Any advice would be greatly appreciated!

Thank you

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
thomas-dmcommented, Mar 2, 2017

I had assumed that Pixi would automatically use the renderer’s resolution for the filters by default, but then I stumbled upon an old thread and saw that it’s been a topic of debate.

Anyway, thanks again! That really helped.

1reaction
ivanpopelyshevcommented, Feb 20, 2017

That can be done. Combine Layer1-2 into new container and use VoidFilter on it, specify correct filterArea.

That way combined result of layer1 + layer2 will be blended on layer0

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Question] Masks performance and HiDPI displays · Issue #3735
I'm using PixiJS 4.3.5. Here's a boiled-down snippet of what I'm doing for the moment: var app = new PIXI.Application(width, height, config); ...
Read more >
macOS Ventura fixed HiDPI issues? :D : r/MacOSBeta - Reddit
So I'm using an 27" 2560 x 1440 165Hz display (msi mag274qrf) on an M1 MacBook Pro and it gave me a terrible...
Read more >
4K resolution and high DPI: What you need to know about it to ...
This article is about 4K resolution, AKA Ultra HD, which refers to a horizontal screen display resolution in the order of approximately 3840 ......
Read more >
Bug: UI is glitchy and slow on high DPI monitors
I'm on Windows, using a UHD 4K monitor and running 175% display scaling. After Effects scales the UI correctly, but the performance of...
Read more >
Understanding pixel density in the age of 4K - EIZO GLOBAL
A primer about the connection between screen size, resolution, and pixel density in display monitors.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found