Jump to content

Phaser performance issues on Mac


trevb
 Share

Recommended Posts

Hi All,

I'm after a little bit of advice about performance on Mac computers.

My dev machine is a Windows PC with a standard 72dpi 1080p monitor but my boss has an iMac with a 144dpi screen. I also have a 96dpi iMac to test on.

  • The Windows PC @ full screen runs silky smooth
  • The iMac 96dpi manages to give a smooth experience of Phaser at full screen but the Safari browser menus start lagging
  • The iMac 144dpi screen crashes completely at full screen needing a full machine restart

By full screen I mean filling up the browser viewport. The 144dpi Mac performance issues were happening with the browser as a small window of approx 1080p resolution. I am using this code to set the scale of my game:

this.gameWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
this.gameHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);

this.game = new Phaser.Game(this.gameWidth, this.gameHeight, Phaser.AUTO, 'game', {
    preload: this.preload,
    create: this.create,
    update: this.update,
    render: this.render
});

Please note, dragging Safari onto a 72dpi screen that is attached to these Mac's makes them run silky smooth again.

I had a quick search and found a handy little thing called devicePixelRatio which I've temporarily used to resize the canvas by dividing the gameWidth and gameHeight by it. This creates acceptable performance on all machines but now the iMac understandably has some space around the canvas.

this.gameWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0) / devicePixelRatio;
this.gameHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0) / devicePixelRatio;

this.game = new Phaser.Game(this.gameWidth, this.gameHeight, Phaser.AUTO, 'game', {
    preload: this.preload,
    create: this.create,
    update: this.update,
    render: this.render
});

My question is - what's the best way to get Phaser working on these high dpi screens?

Many Thanks - Trev

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...