Closed Bug 595655 Opened 14 years ago Closed 14 years ago

Enabling D2D causes performance regression of canvas game (biolab disaster) by 60%

Categories

(Core :: Graphics: Canvas2D, defect)

x86
Windows 7
defect
Not set
major

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: kbrosnan, Assigned: bas.schouten)

References

()

Details

(Keywords: regression)

Visit the url in a current nightly on Windows 7 or Vista. Press x to start a game and f to show the frame rate. For me the frame rate is around 25. Set  mozilla.widget.render-mode to 0 and restart Firefox. Visit the game, start it and check the frame rate. For me it shows 62.

Author mentioned that the previous betas were at the max frame rate of ~60.

Adapter Description NVIDIA GeForce GT 240M
Vendor ID10de
Device ID0a34
Adapter RAM1024
Adapter Driversnvd3dumx,nvwgf2umx,nvwgf2umx nvd3dum,nvwgf2um,nvwgf2um
Driver Version8.17.12.5896
Driver Date7-9-2010
Direct2D Enabled true
DirectWrite Enabled true 
GPU Accelerated Windows1/1 Direct3D 9
blocking2.0: --- → ?
Author will supply a different testcase.
Updated url to the testcase http://www.phoboslab.org/crap/perftest/ with this test I get about 17 fps with mozilla.widget.render-mode -1 and 60fps with mozilla.widget.render-mode 0.
I'm the author of the Test case. I have about 12 fps with mozilla.widget.render-mode -1 and 50 fps with mozilla.widget.render-mode 0.

Adapter DescriptionNVIDIA GeForce 8800 GTS
Vendor ID10de
Device ID0193
Adapter RAM640
Adapter Driversnvd3dumx,nvwgf2umx,nvwgf2umx nvd3dum,nvwgf2um,nvwgf2um
Driver Version8.17.11.9621
Driver Date1-11-2010
Direct2D Enabled true
DirectWrite Enabled true
GPU Accelerated Windows1/1 Direct3D 9
Where does the actual code for the testcase live, that uses canvas?  Can't figure out how to look at that source.. Does the testcase use globalCompositeOperator at all?  If so, what operators does it use?
This test case draws two "background maps" on top of each other. It uses a "tileset" and draws little 8x8 pixel chunks of it. Here's the code that draws the map:
http://www.phoboslab.org/****/perftest/lib/impact/background-map.js

The "drawTile" function is just a wrapper around ctx.drawImage() and can be found here:
http://www.phoboslab.org/****/perftest/lib/impact/image.js

Here's the tileset from which the 8x8 tiles are drawn:
http://www.phoboslab.org/****/perftest/media/biolab.png
Moving this over from bug 596321. Regression range is (8/15-8/16 in
http://hg.mozilla.org/mozilla-central/pushloghtml?startdate=8%2F14%2F2010&enddate=8%2F16%2F2010).

The game i found this on was "Biolab Disaster" ( http://www.phoboslab.org/biolab/ ).
The original URL for this bug actually was the "Biolab Disaster" game. It just wasn't meant to be "public" at the time. 

You can press F when the game is running to see the current frame-rate. It's capped at 60fps. The drawing code is the same as in the http://www.phoboslab.org/****/perftest/ test case though.
(In reply to comment #7)
The regression range just shows when direct2d was enabled by default.
Assignee: nobody → bas.schouten
blocking2.0: ? → final+
Summary: Setting mozilla.widget.render-mode 0 increases performance of canvas game by 60% → Enabling D2D causes performance regression of canvas game (biolab disaster) by 60%
It seems the FPS is fine now. But there are some stoppages, especially when someone shoots, dies, or jumps.
http://hg.mozilla.org/mozilla-central/rev/a9d1ad0bc386
Is that link supposed to have any relevance? 

Could be that the stoppages are due to the Javascript garbage collector.
That was my build's changeset.
The stoppages are still here with D3D10, too, but they are much rare and much shorter with D3D10 than D3D9.

BTW, the FPS is OK now.
D2D performance ---> CC Bas
I'm curious, does this test use globalCompositeOperator somehow? If it doesn't I'll investigate this soon.
Bas: I get little stoppages with the perftest, too. They are happening always at the same interval.

Please try the game, not just the test! We got little stoppages on the game, when somebody dies, shoots or jumps.
Hmm, that bluriness seems to be global.

http://github.com/sinatra/sinatra/network
With D3D9+D2D game play is rather smooth in Biolab for me except for what I think is the Javascript GC kicking, but it's gotten worse with D3D10+D2D as Csaba stated when an enemy is gibbed. The difference between D3D9 and D3D10 is especially noticeable at the end of the demo when the white sparks are congregating.
(In reply to comment #16)
> Bas: I get little stoppages with the perftest, too. They are happening always
> at the same interval.
> 
> Please try the game, not just the test! We got little stoppages on the game,
> when somebody dies, shoots or jumps.

Bas: any feedback on this? Others said it's maybe it's a GC problem.
(In reply to comment #19)
> (In reply to comment #16)
> > Bas: I get little stoppages with the perftest, too. They are happening always
> > at the same interval.
> > 
> > Please try the game, not just the test! We got little stoppages on the game,
> > when somebody dies, shoots or jumps.
> 
> Bas: any feedback on this? Others said it's maybe it's a GC problem.

My only feedback is that I can't see how the GFx code could result in brief stoppages, certainly in slow framerates, but not stoppages I'd say.

Having said that, I don't see why GCs would occur synchronized with the player dying, shooting or jumping so I'm not sure how that could explain it. But I'm no Javascript expert.

I don't see how D3D9 could possibly suffer from it less than D3D10 at all though. That sounds like test noise, but I might be wrong.
(In reply to comment #20)
> I don't see how D3D9 could possibly suffer from it less than D3D10 at all
> though. That sounds like test noise, but I might be wrong.

Yeah, i'm not sure in that.

BTW, should i file a separate bug CCing the JS guys?

Any you see the stoppages, dont you?
(In reply to comment #21)
> (In reply to comment #20)
> > I don't see how D3D9 could possibly suffer from it less than D3D10 at all
> > though. That sounds like test noise, but I might be wrong.
> 
> Yeah, i'm not sure in that.
> 
> BTW, should i file a separate bug CCing the JS guys?
> 
> Any you see the stoppages, dont you?

Nope, I don't see any stoppages, game is very smooth for me using D3D10 layers, GT230M with Core i7 mobile.
Hmm, i still see them, with any layers, fresh profile. I'll ask some forums for confirmation.
http://www.phoboslab.org/****/perftest/

In that benchmark I don't see any difference between D3D9/D3D10. It's difficult to read the FPS but it's well over 60 fps, around 77-83 fps. 

In the actual game though I still see serious performance differences. Perhaps you can test on a slower machine Bas? Like a dual core with no hyperthreading - more representative of the average user. Most people will probably have Intel graphics card too.
I tested on a T6600. I realized that the problem is high CPU usage. With fresh profile, it uses 30-40% CPU, but in my addon-crowded everyday profile, it uses the whole core. That caused the stoppages. I guess if there is a problem, it's JS related.
With the lastest D2D+D3D patches D3D10 performance is as fast as D3D9 if not faster for me so I suppose the issue is WFM now.
Can someone confirm this is fixed for everyone now? Otherwise I'll need to investigate further.
It's fixed, Bas.

My high CPU and stoppages problem is not related to HW ACC, i guess if it's a bug, it's a JS bug.
I get 60 fps with Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0b8pre) Gecko/20101017 Firefox/4.0b8pre. Clearing blocking and marking works for me.

Adapter Description NVIDIA GeForce GT 240M
Vendor ID 10de
Device ID 0a34
Adapter RAM 1024
Adapter Drivers nvd3dumx,nvwgf2umx,nvwgf2umx nvd3dum,nvwgf2um,nvwgf2um
Driver Version8.17.12.6063
Driver Date 9-10-2010
Direct2D Enabled true
DirectWrite Enabled true
GPU Accelerated Windows3/3 Direct3D 9
Status: NEW → RESOLVED
blocking2.0: final+ → ---
Closed: 14 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.