Archived issue #0032723

Draw Harness, ViewerTest - sloppy animation in WebGL

Open CASCADEOCCT:DRAWclosed7 public notes

Search issues

Description

Running animation in WebGL shows FPS higher than possible with VSync (like 100-200 FPS on 60Hz display).

Opening a complex scene reveals the problem - these extra frames are duplicates, so that FPS looks high, while animation becomes sloppy and overall application experience becomes slow.

One issue is with emscripten_async_call() called with 0 argument redirecting to setTimeout().
Instead, viewer animation was expected to be handled by emscripten_async_call() with -1 argument redirecting to requestAnimationFrame().

Another issue is that command "vanimation" calls ViewerTest_EventManager::ProcessExpose(), which queues next update via emscripten_async_call(), but if update was already queued - updates are doubled (or further multiplied in worse case) leading to bad animation performance (several frames are redrawn while user sees only one update).

Steps to reproduce

Scenario 1:
- Start WebGL sample or Draw Harness session with 3D Viewer.
- Start clicking on View Cube rapidly to initiate animation and check for FPS.
Result: FPS might exceed VSync limit.

Scenario 2:
- Open a complex scene.
- Enable expensive features like Depth Peeling.
- Start animation.
Result: on slow hardware (e.g. mobile phone) demonstrated FPS looks fine, but experienced performance is obviously worse.

pload XDE MODELING VISUALIZATION
box b1   0   0 0 50 50 50
box b2 150   0 0 50 50 50
box b3   0 150 0 50 50 50
vinit View1
vdisplay -dispMode 1 b1 b2 b3
vfit
vaspects b1 -color RED -transparency 0.5
vaspects b2 -color RED -transparency 0.5
vaspects b3 -color RED -transparency 0.5
vtorus t1 50 25
vtorus t2 50 25
vtorus t3 50 25
vlocation t1 -reset -rotate 0 0 0 0 1 0 90 -translate 175 175 -125
vaspects  t1 -color GREEN -transparency 0.5
vlocation t2 -reset -rotate 0 0 0 0 1 0 90 -translate 175 175 25
vaspects  t2 -color GREEN -transparency 0.5
vlocation t3 -reset -rotate 0 0 0 0 1 0 90 -translate 25 175 -125
vaspects  t3 -color GREEN -transparency 0.5

set NB 3
for {set i 0} {$i < $NB} {incr i} {
  for {set j 0} {$j < $NB} {incr j} {
    for {set k 0} {$k < $NB} {incr k} {
      psphere s$i$j$k 25.0
      ttranslate s$i$j$k 100.*$i 100.*$j -100.*$k
      vdisplay -dispMode 1 s$i$j$k
      vaspects s$i$j$k -color BLUE -transparency 0.5
    }
  }
}

# define camera animation
vcamera -persp
vaxo
vfit
vanim a/v1 -start  0.0 -end  5.0 -view -eye1  96 -515 -68 -eye2 -507   88 -68 -at1 96 88 -68 -at2 96 88 -68 -up1 0 0 1 -up2 0 0 1 -scale1 2 -scale2 2
vanim a/v2 -start  5.0 -end 10.0 -view -eye1 -507  88 -68 -eye2   96  691 -68 -at1 96 88 -68 -at2 96 88 -68 -up1 0 0 1 -up2 0 0 1 -scale1 2 -scale2 2
vanim a/v3 -start 10.0 -end 15.0 -view -eye1  96  691 -68 -eye2  699   88 -68 -at1 96 88 -68 -at2 96 88 -68 -up1 0 0 1 -up2 0 0 1 -scale1 2 -scale2 2
vanim a/v4 -start 15.0 -end 20.0 -view -eye1  699  88 -68 -eye2   96 -515 -68 -at1 96 88 -68 -at2 96 88 -68 -up1 0 0 1 -up2 0 0 1 -scale1 2 -scale2 2

vrenderparams -perfCounters fps
vrenderparams -oit peel 8
vanim a/v1 0.0 5.0

Public activity

7 archived notes

Participants are labeled by their role within this record.

01Commenter 1
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Tue Dec 7 20:07:04 2021 +0300

    0032723: Draw Harness, ViewerTest - sloppy animation in WebGL
    
    Fixed emscripten_async_call() calls to use requestAnimationFrame() instead of setTimeout().
02Commenter 1
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
03Commenter 1
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
04Author
Patch is ready for review
- OCCT: branch CR32723.

http://jenkins-test-12.nnov.opencascade.com:8080/view/CR32723-master-KGV/
05Commenter 5
The patch was reviewed
06Commenter 6
Combination -
OCCT branch : [archived branch]
master SHA - [revision removed]
[revision removed]
Products branch : [archived branch] SHA - [revision removed]
was compiled on Linux, MacOS and Windows platforms and tested in optimize mode.

Number of compiler warnings:
No new/fixed warnings

Regressions/Differences/Improvements:
No regressions/differences

CPU differences:
Debian80-64:
OCCT
Total CPU difference: 18222.380000000427 / 18166.60000000042 [+0.31%]
Products
Total CPU difference: 11645.100000000084 / 11658.820000000103 [-0.12%]
Windows-64-VC14:
OCCT
Total CPU difference: 19999.4375 / 19937.953125 [+0.31%]
Products
Total CPU difference: 13044.453125 / 13069.28125 [-0.19%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention
07Commenter 1
Branch [archived branch] has been deleted by Participant.

[revision removed]