June 11, 2019

When Firefox works better than Chrome

Most of people use the Chrome browser, and Photopea always worked perfectly in Chrome. But there are more and more cases, when we have to recommend using Firefox instead of Chrome.

We will discuss a specific issue, which is not possible to overcome in Chrome nowadays, but can be easily performed in Firefox.

Bits and Bytes

Photopea uses 8 bits (1 byte) to represent a sample of a color. We use four samples for each pixel: for red, green, blue and a transparency values. So we need 4 bytes of memory to represent one pixel of the image.

Let's say a layer in a document is 10 000 x 10 000 pixels (or 100 megapixels, 100 millions of pixels). We need 400 MB of memory to store such layer. When there are 20 such layers, it requires 8 GB of memory.

Such huge image documents are not rare at all. Many people use Photopea to convert vector formats, such as Sketch or XD, into a PSD format. Each vector shape has to be rasterized. Even if it is a simple rectangle filled with a solid color, it will use 4 bytes for each pixel.

Also, each layer style (such as Drop Shadow, Inner Glow, Gradient Overlay or Stroke) creates a new pixel image, requiring the same amount of memory, as the original layer. So 20 layers are as large as 4 layers with 4 styles in each layer.

Chrome vs. Firefox

There is a bug in Google Chrome: Chrome will "kill" any website, which tries to use more than 4 GB of RAM. Even when your computer has 32 GB of RAM, you can not open a document with 5 GB of pixel data. It has been reported to a bug tracker back in 2014, but was closed without fixing it. Now, it is reported again, and we hope it will be fixed eventually.

Fortunatelly, Firefox does not have such problem, so we recommend it to our users with Chrome, who need to process a large document.