CPU Bug "Limited by Main Thread" is causing the bad FPS

Nice find!

I will check it in a couple of hours and get back to you, let’s check if this works!

This happens on my Ryzen 7 2700X, Sapphire RX5700XT Nitro + 16gb DDR4 RAM at 3333mhz XPG SX8200 Pro SSD , lets hope in the future we get DIrext X 12 , so results like this will not happen

I did some tests and it seems to work as a temporary solution. On my system (a gaming laptop with i7 8750h and RTX2080) the CPU is still the bottleneck, but I can see a 10-15 FPS gain in the airliners.

It’s super easy to try and you don’t risk to break anything in the sim. The file to edit is found here:

MS Store version: C:\Users\YOURNAME\AppData\Local\Packages\Microsoft.FlightSimulator_RANDOMCODE\LocalCache\Packages\Official\OneStore\asobo-vcockpits-instruments\html_ui\Pages\VCockpit\Instruments\Shared\BaseInstrument.js

Steam version:
C:\Users\YOURNAME\AppData\Local\Packages\Microsoft.FlightSimulator_RANDOMCODE\LocalCache\Packages\Official\Steam\asobo-vcockpits-instruments\html_ui\Pages\VCockpit\Instruments\Shared\BaseInstrument.js

To edit the BaseInstrument.js file I suggest to use a code editor as Notepad++ or Sublime Text (both free). Backup the file making a copy on your desktop to restore it in case you encounter any problem.

This is the part to be edited (line 235 in my case but may be different):

CanUpdate() {
        var quality = this.getQuality();
        if (quality == Quality.high) {
            if ((this.frameCount % 3) != 0) {
                return false;
            }
        }	
        if (quality == Quality.medium) {
            if ((this.frameCount % 8) != 0) {
                return false;
            }
        }
        else if (quality == Quality.low) {
            if ((this.frameCount % 32) != 0) {
                return false;
            }
        }
        else if (quality == Quality.hidden) {
            if ((this.frameCount % 128) != 0) {
                return false;
            }
        }
        else if (quality == Quality.disabled) {
            return false;
        }
        return true;
    }

if you don’t have this part (it wasn’t present in my case), just paste it in:

        if (quality == Quality.high) {
            if ((this.frameCount % 3) != 0) {
                return false;
            }
        }	

Consider that Quality.high is the chunk of code used when you are in cockpit, the other quality options are for lower LODs (external views or drone camera based on distance from the plane).
The number you enter here if ((this.frameCount % 3) != 0) (3 in my case) is the glass cockpit instruments FPS subdivision coefficient based on your screen refresh rate (my screen is 144Hz so divided by 3 means the glass cockpit will work at 48 Hz, you can try different numbers based on your display Hz and CPU power).

If you want to do tests with different coefficients you don’t need to close and reopen the program, just exit to main menu and repeat the flight.

Some tests with the A320 in the middle of nowhere in Africa and with Clear Skyes at midday

if ((this.frameCount % 1) != 0) (basically the default option with no division coefficient):

if ((this.frameCount % 3) != 0) (instruments working at 48Hz, very usable):

if ((this.frameCount % 8) != 0) (instruments working at 18Hz, very choppy):

Happy modding :wink:

7 Likes

Thank you this gave me roughly 5-10FPS more, still more optimizations to be done with such aircraft, but for the moment this is a great fix!

1 Like

I opened a new thread for this, hoping more people can find it: Small JS config file mod to get better performance in airliners and glass cockpit planes

We can only hope that as part of the continued development, this is recoded so that it uses a more acceptable refresh rate, and also something more performant tha JavaScript

1 Like

still no solution for the “limited by main thread” problem…

I guess that will require some direct changes in the core code by the devs and may take some time. But at least the ContentGTDraw issue is taken care of!

This folder does not exist in my pc: Microsoft.FlightSimulator_RANDOMCODE
Is there any other place I can find it?

This is very strange. Are you sure it is not hidden?

This is the correct path, I found the answer in reddit, in Steam the folder is in a different place apparently :wink:
C:\Users\YOURNAME\AppData\Roaming\Microsoft Flight Simulator\Packages\Official\Steam\asobo-vcockpits-instruments\html_ui\Pages\VCockpit\Instruments\Shared

1 Like

The Folder is only placed in AppData if you do not changed the installdrive… for example on my machine:

D:\FS2020\Official\Steam\asobo-vcockpits-instruments\html_ui\Pages\VCockpit\Instruments\Shared

This solves the issue guys

7 Likes

Indeed, that is true. However, not allocating weighted tasks properly is called “bad optimization” in video games. What we are seeing is bad optimization.

1 Like

Replying to confirm that line 235 was the location for me as well.

3 Likes

I can confirm: this one really works for me. All the other solutions floating around didn’t do anything. This one I’d say gives me 5 to 10 frames more in the airliners. I do notice the instruments are less smooth, but that’s a very small sacrifice.

2060 RTX / i7 / 144hz screen refresh

2 Likes

Is there a way that this modified BaseInstrument.js file could be placed in the Community folder so it will override the original, rather than modifying the original?

2 Likes

Following up after a flight. Prior to editing, I averaged 40 FPS on Ultra. After editing, I am now reaching 100-110 FPS average(Dug around the code and found a few extra things to tweak as well, still configuring before I finalize a post). Instruments are choppy at 0, but easy to get used to until Microsoft realizes they omitted a section of code.

To note: I fly in the mid-west. No cities, flights were done during the day time, overcast skies, no traffic.

2700x w. 5.1 GHz overclock/2080 Super w. 2145 MHz core overclock/64 GB (4,200 MHz) RAM/165 Hz display.

1 Like

Thank you, the code means nothing to me :joy:, I’m glad there’s people who understand it and can optimise it! :+1:

1 Like