Closed Bug 827229 Opened 11 years ago Closed 11 years ago

[B2G]Enhance 2D canvas performance on B2G

Categories

(Core :: Graphics: Canvas2D, defect)

All
Gonk (Firefox OS)
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla26

People

(Reporter: pchang, Assigned: pchang)

References

Details

Running the game testing, B2G got 36.41 fps and Android got 47.88 fps
http://www.craftymind.com/factory/guimark2/MobileHTML5GamingTest.html

Try to enable SkiaGL and compare result again
Assignee: nobody → pchang
Component: General → Canvas: 2D
Product: Boot2Gecko → Core
So this uses setInterval() instead of requestAnimationFrame; that by default is going to be unstable/awful.  Otherwise, all this does is scaled drawImage, which, admittedly, is a sweet spot for any GL acceleration.

But when you say Android got 47.88 -- do you mean the stock Android browser on the same device before you put b2g on it, or Firefox for Android on the same device, or what?
Update more detail testing results

Use two unagi devices for testing, one for b2g and another one for android 4.0.4.
a. Original browser on Android   47.88/44.68/46.36 fps
b. Firefox browser on Android    28.62/29.01/29.43 fps
c. B2G browser                   36.41/36.16/36.06 fps

For case a/b, I think the hardware acceleration is enabled on profiling android device because GPU interrupt counters change and composition type of surfaceflinger is HWC.

P.S. Check GPU interrupt counter
     peter@peternb:~$ watch -n 0.3 "adb shell cat /proc/interrupts|grep kgsl"

But I'm not sure why case b only gets about 29 fps.
For case c, it is used cairo by default.

Right now I'm trying to enable skiaGL to check the result.

As you mentioned, setInterval() causes the result unstable. Is there any proper HTML5 canvas benchmark I can refer to? If so, I can provide the data with new app.
Update another game result

[Cuttherope]
 - Lots of drawpath calls with small sample size
 - Switch to software path renderer because anti-alias required for above drawpath calls and cause lots memcpy for texture upload

 - Result
   - skia   50-52 fps  CPU  80%
   - skiaGL 30-23 fps  CPU  55%

For Cuttherope, js and render are using the same thread, therefore fps/cpu usage decreases when GPU stall during texture upload uploading.

I think the possible solutions are adding texture cache for drawpath case or using sw/hw combination for 2D canvas.
Update benchmark result of chrome on Android

[Environment]
  Google Nexus S with android 4.1.2

[Result/fps]
Two benchmarks
 - guimark2
 - guimark2 without backgroud image update
 - cuttherope

 a. chrome beta: Hardware accelerated 2D enabled
	guimark2_nobk 26.77
        guimark2      26.9
	cuttherope    18

 b. chrome beta: Hardware accelerated 2D disabled
        guimark2       4.3(very slow, looks like chrome's bug)
        guimark2 _nobk 3  (very slow, looks like chrome's bug)
	cuttherope     8.5

 c. chrome: Hardware accelerated 2D enabled by default
	guimark2_nobk 34
        guimark2      30
	cuttherope    26

 d. firefox from android market: Hardware accelerated 2D disabled(no skiaGL)
        guimark2_nobk 30
	guimark2      27
        cuttherope    35

 e. native android browser
        guimark2_nobk 55
	guimark2      53
        cuttherope    42

Will update firefox mobile with skiaGL soon.

For chrome beta app result, looks like the performance is not optimizated and some testing items have problem.
FWIW, the native android browser should be using SkiaGL as well.
update firefox mobile with skiaGL from George

 f. firefox from android market: Hardware accelerated 2D enabled
        guimark2_nobk 45
	guimark2      44.18
        cuttherope    can't run because texture too big
Whiteboard: [b2g-gfx]
Now I'm able to enable skiaGL on b2g based on m-c branch.
The following are the comparison results between firefox mobile and b2g.

[Environment]
  ZTE open with HVGA display

[Result/fps]
- Running guimark2
  a. firefox mobile with skiaGL - fps changes from 38 -> 45
  b. B2G with skiaGL enabled    - fps changes from 40 -> 50
                                  CPU usage changes from 90% -> 70%

As shown above, B2G with skiaGL also got better result.

One more thing, the background of guimark2 on B2G will generate another thebeslayer and consume lots of CPU resources for drawing.
If I remove this background, the fps on B2G can reach to 55 fps.

Therefore, B2G can get better result if hardware acceleration of 2D content supports.
Are you seeing flickering with guimark2 on B2G/SkiaGL?
No, I didn't see flicker issue on B2G/skiaGL.
Or you can share the firefox mobile to me to check.
How are these numbers now with SkiaGL as the default for canvas?
Whiteboard: [b2g-gfx]
By using latest m-c branch, 2D canvas is using skiaGL by default.
The following are new fps for guimark2 with background.

I think we could close this case now.

[Environment]
  Leo with HVGA display

[Result/fps]
- Running guimark2
  b. B2G with skiaGL enabled    - fps improves to 58
              CPU usage data
              61% guimark2        /system/b2g/plugin-container
              20% Compositor      /system/b2g/b2g
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Depends on: 905214
Target Milestone: --- → mozilla26
(In reply to peter chang[:pchang] from comment #11)
> By using latest m-c branch, 2D canvas is using skiaGL by default.
> The following are new fps for guimark2 with background.
> 
> I think we could close this case now.
> 
> [Environment]
>   Leo with HVGA display
> 
> [Result/fps]
> - Running guimark2
>   b. B2G with skiaGL enabled    - fps improves to 58
>               CPU usage data
>               61% guimark2        /system/b2g/plugin-container
>               20% Compositor      /system/b2g/b2g

That's great, Peter, thanks for these results.  Any chance of getting the Chrome/Firefox Mobile/Native Android numbers on the "same hardware" for quick comparison?
Flags: needinfo?(pchang)
(In reply to Milan Sreckovic [:milan] from comment #12)
> (In reply to peter chang[:pchang] from comment #11)
> > By using latest m-c branch, 2D canvas is using skiaGL by default.
> > The following are new fps for guimark2 with background.
> > 
> > I think we could close this case now.
> > 
> > [Environment]
> >   Leo with HVGA display
> > 
> > [Result/fps]
> > - Running guimark2
> >   b. B2G with skiaGL enabled    - fps improves to 58
> >               CPU usage data
> >               61% guimark2        /system/b2g/plugin-container
> >               20% Compositor      /system/b2g/b2g
> 
> That's great, Peter, thanks for these results.  Any chance of getting the
> Chrome/Firefox Mobile/Native Android numbers on the "same hardware" for
> quick comparison?

I will try to get the android device for testing again.
Flags: needinfo?(pchang)
You need to log in before you can comment on or make changes to this bug.