<html>
    <head>
      <base href="https://bugs.documentfoundation.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_UNCONFIRMED "
   title="UNCONFIRMED - The while loop for Javascript presentation engine"
   href="https://bugs.documentfoundation.org/show_bug.cgi?id=107561">107561</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>The while loop for Javascript presentation engine
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>LibreOffice
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>5.3.2.2 release
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>UNCONFIRMED
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Impress
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>libreoffice-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>wanliyou@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Description:
Seems like exported JS presentation engine is directly generated from cpp
version, here:
<a href="https://github.com/LibreOffice/core/blob/2eae33e82e5f91d6dbaf7e8e848f53644596059d/slideshow/source/engine/slideshowimpl.cxx#L2370">https://github.com/LibreOffice/core/blob/2eae33e82e5f91d6dbaf7e8e848f53644596059d/slideshow/source/engine/slideshowimpl.cxx#L2370</a>

The generated JS looks like this:
FrameSynchronization.prototype.synchronize = function()
{
if( this.bIsActive )
{
while( this.aTimer.getElapsedTime() < this.nNextFrameTargetTime )
;

this.markCurrentFrame();
}

The while loop will be CPU hogging and make the UI no response, so I think this
kind of code should be optimized to schedule in a Timer/requestAnimationFrame.

FrameSynchronization.prototype.synchronize = function()
{
if ( this.bIsActive && ( this.aTimer.getElapsedTime() <
this.nNextFrameTargetTime )) {
   setTimeout(this.synchronize.bind(this), 16);
}
else {
   this.markCurrentFrame();
}
}



Steps to Reproduce:
1. Open a slide with long time animations
2.
3.

Actual Results:  
CPU hogging and janky animation

Expected Results:
Smooth animation and use much lesser CPU cycles.


Reproducible: Always

User Profile Reset: No

Additional Info:


User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>