Why is Firefox so slow when compared to Chrome when used for HTML5 gaming (“Forge of Empires”)?

1

I am on my laptop just contemplating on transitioning one Flash game I play (“Forge of Empires”) that is currently available in HTML5. I’m having a difficult time comprehending why the Firefox is so slow compared to Chrome.

OS + HW + Browsers

Operating System:

Hardware:

  • CPU: Intel® Core™ i7-7700HQ, 7th gen., 2.80 - 3.80 GHz, grep flags /proc/cpuinfo:

    fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d
    
  • RAM: 32 GB DDR4 2400MHz dual-channel (update, recently switched)

  • GPU: NVIDIA GeForce GTX 1060, Max-Q Design, 6GB of memory
  • Display: integrated laptop display, 15.6 inches, resolution 3840x2160
  • Game: Forge of Empires

Web Browsers:


HTML5 Benchmark Tool

I have taken HTML5 AnTuTu Benchmark measurements as I am unsure of another HTML5 benchmark, see below:

AnTuTu in Chrome:


AnTuTu in Chrome


AnTuTu in Firefox:


AnTuTu in Firefox


I have done those tests on Windows now, and I see no big difference to be tempted on putting it into this question.

LinuxSecurityFreak

Posted 2019-02-26T09:56:41.767

Reputation: 2 298

It's worse in some and better in others. Did you check whenever it has an impact on that game? Both use different engines that are optimized for different things. – Seth – 2019-02-26T10:07:21.287

Not the game, the browser engines. Chrome and Firefox use different engines to render their content. They have different scenarios they optimize for. – Seth – 2019-02-26T10:25:27.263

You play the game and find out if it has a problem. – Mokubai – 2019-02-26T10:38:19.650

Answers

1

Hardware bottleneck found


While playing the game, the slow-downs I call tearing are caused by high CPU usage in Firefox.


This HTML5 game in Firefox

Game in Firefox


This HTML5 game in Chrome

Game in Chrome


It might very well behave differently in other games, so I'm not making any conclusions here.


Resolution / Plausible fix

What helped this game was enabling the following in the about:config:

layers.acceleration.force-enabled

Also, I noticed a bit of performance increase with today's update to version 71.0 (71.0+linuxmint2+tricia, official release notes), it may be just my feeling, though.

The game now feels noticeably faster, try it out for yourself!


It appears that most of the graphics-heavy work-load now lies / has been off-loaded onto my GPU as per this top snippet:

top - 07:59:30 up  3:23,  1 user,  load average: 1,44, 0,86, 0,77
Tasks: 256 total,   2 running, 193 sleeping,   0 stopped,   0 zombie
%Cpu(s): 11,0 us,  5,4 sy,  0,0 ni, 83,5 id,  0,0 wa,  0,0 hi,  0,2 si,  0,0 st
KiB Mem : 32669556 total, 25297888 free,  4186864 used,  3184804 buff/cache
KiB Swap:        0 total,        0 free,        0 used. 27273988 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND      
 5466 vlastim+  20   0 3359676 554668 150028 S  11,0  1,7  33:18.16 Web Content  
 5387 vlastim+  20   0 1131428 497656 299124 S  21,3  1,5  32:23.13 GPU Process  
 5352 vlastim+  20   0 3835144 553044 238576 S  12,0  1,7  24:04.95 firefox      

and confirmed by this nvidia-smi snippet:

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 435.21       Driver Version: 435.21       CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 106...  Off  | 00000000:01:00.0  On |                  N/A |
| N/A   50C    P0    40W /  N/A |   1346MiB /  6078MiB |     48%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1413      G   /usr/lib/xorg/Xorg                           503MiB |
|    0      2799      G   cinnamon                                     139MiB |
|    0      5352      G   /usr/lib/firefox/firefox                       2MiB |
|    0      5387      G   /usr/lib/firefox/firefox                     443MiB |
|    0     12394      G   /usr/lib/firefox/firefox                     254MiB |
+-----------------------------------------------------------------------------+

LinuxSecurityFreak

Posted 2019-02-26T09:56:41.767

Reputation: 2 298

-3

This can happen because Firefox and Chrome use two different ways of managing main memory (RAM). You often see that Chrome uses lots of memory and battery of our devices. This is because Chrome treats each tab you open up as a new web browser instance, and allocates a separate memory block, while Firefox uses the traditional method of memory management. It allocates a big chunk of memory to the application. As you open more tabs, a small part from this allocation gets allocated to each new tab, so as you open more tabs Firefox slows down.

Hope this will help you. Thank you.

HarshShah

Posted 2019-02-26T09:56:41.767

Reputation: 60

Multiply false answer: 1) firefox is multi-process since many years ago (google for: firefox serialisation). 2) doing this is not "allocating big chunk of memory", dynamic memory allocation allocates ram always what is needed, and so is it many decades ago. 3) it is also questionable, if switching to the multi-process had been a good idea, I think it was not, but it is another topic. – peterh - Reinstate Monica – 2019-12-09T13:41:54.353