Bug 115896 - [BlackBerry] Use requestAnimationFrame for animations
Summary: [BlackBerry] Use requestAnimationFrame for animations
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit BlackBerry (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-10 03:42 PDT by Carlos Garcia Campos
Modified: 2013-05-14 09:16 PDT (History)
7 users (show)

See Also:


Attachments
Patch (8.09 KB, patch)
2013-05-10 03:48 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Updated patch (7.97 KB, patch)
2013-05-10 05:12 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Updated patch (8.24 KB, patch)
2013-05-13 03:35 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Another update (8.12 KB, patch)
2013-05-13 03:45 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from webkit-ews-16 for mac-mountainlion-wk2 (1.25 MB, application/zip)
2013-05-13 17:28 PDT, Build Bot
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Garcia Campos 2013-05-10 03:42:34 PDT
This way we don't need the changes proposed in bug #114501 to get 60fps in the BlackBerry port.
Comment 1 Carlos Garcia Campos 2013-05-10 03:48:40 PDT
Created attachment 201330 [details]
Patch
Comment 2 Arvid Nilsson 2013-05-10 04:03:57 PDT
Comment on attachment 201330 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=201330&action=review

The only call that will happen on a non-UI thread is animationFrameChanged(), perhaps we can invent a "weak" synchronization scheme similar to void WebPagePrivate::updateDelegatedOverlays(bool duringCommit, bool dispatched) to avoid using a mutex.

> Source/WebKit/blackberry/Api/WebPage.cpp:6333
> +    BlackBerry::Platform::AnimationFrameRateController::instance()->lockMutex();

Since addClient() already locks/unlocks the internal mutex, is this external lock/unlock pair really necessary? Perhaps it tries to use the mutex to protect m_isRunningRefreshAnimationClient, since stopRefreshAnimationClient is sometimes called on the UI thread (when it's called from animationFrameChanged)?
Comment 3 Carlos Garcia Campos 2013-05-10 04:10:27 PDT
(In reply to comment #2)
> (From update of attachment 201330 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=201330&action=review
> 
> The only call that will happen on a non-UI thread is animationFrameChanged(), perhaps we can invent a "weak" synchronization scheme similar to void WebPagePrivate::updateDelegatedOverlays(bool duringCommit, bool dispatched) to avoid using a mutex.
> 
> > Source/WebKit/blackberry/Api/WebPage.cpp:6333
> > +    BlackBerry::Platform::AnimationFrameRateController::instance()->lockMutex();
> 
> Since addClient() already locks/unlocks the internal mutex, is this external lock/unlock pair really necessary? Perhaps it tries to use the mutex to protect m_isRunningRefreshAnimationClient, since stopRefreshAnimationClient is sometimes called on the UI thread (when it's called from animationFrameChanged)?

I took this approach from the BlackBerry::Platform::AnimationBase implementation, but I think the mutex in this case is to call frameChanged with the lock, so maybe we don't need it here.
Comment 4 Carlos Garcia Campos 2013-05-10 05:12:38 PDT
Created attachment 201336 [details]
Updated patch

Removed the mutexes and added early return in scheduleAnimation
Comment 5 Arvid Nilsson 2013-05-10 05:30:00 PDT
Comment on attachment 201336 [details]
Updated patch

View in context: https://bugs.webkit.org/attachment.cgi?id=201336&action=review

> Source/WebKit/blackberry/Api/WebPage.cpp:6312
> +void WebPagePrivate::animationFrameChanged()

Now to be sure there are memory barriers all over the place (when dispatching messages, locking mutexes etc)
but just looking at these two methods in isolation...

> Source/WebKit/blackberry/Api/WebPage.cpp:6329
> +}

In the complete absence of memory barriers, scheduleAnimation() could set m_animationScheduled to true on Core 1, but that change is not synced over to Core 2, and when core 2 executes animationFrameChanged(), it will just stop and return.
Comment 6 Arvid Nilsson 2013-05-10 05:33:07 PDT
there's also a "one shot" mode of operation for AnimationFrameRateController that might be more appropriate for the RAF usage, see WebPageCompositorPrivate for an example of one shot AFRClient
When useing the one shot flavour, you don't have to manually remove yourself
Comment 7 Andrew Lo 2013-05-10 09:16:49 PDT
Comment on attachment 201336 [details]
Updated patch

looks good to me
Comment 8 Carlos Garcia Campos 2013-05-13 03:35:22 PDT
Created attachment 201542 [details]
Updated patch

Added a mutex following the same approach as DisplayRefreshMonitor
Comment 9 Carlos Garcia Campos 2013-05-13 03:45:17 PDT
Created attachment 201544 [details]
Another update

Sorry, attached the wrong patch, this one should apply.
Comment 10 Arvid Nilsson 2013-05-13 03:55:48 PDT
Comment on attachment 201544 [details]
Another update

This looks pretty much exactly like the old code, and looks threadsafe to me. Informal R+
Comment 11 Build Bot 2013-05-13 17:28:57 PDT
Comment on attachment 201544 [details]
Another update

Attachment 201544 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/460868

New failing tests:
editing/unsupported-content/table-delete-003.html
editing/unsupported-content/list-type-before.html
editing/unsupported-content/table-type-before.html
editing/unsupported-content/list-delete-003.html
editing/unsupported-content/list-delete-001.html
editing/unsupported-content/list-type-after.html
editing/unsupported-content/table-delete-002.html
editing/unsupported-content/table-type-after.html
editing/unsupported-content/table-delete-001.html
Comment 12 Build Bot 2013-05-13 17:28:59 PDT
Created attachment 201648 [details]
Archive of layout-test-results from webkit-ews-16 for mac-mountainlion-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: webkit-ews-16  Port: mac-mountainlion-wk2  Platform: Mac OS X 10.8.2
Comment 13 Rob Buis 2013-05-14 08:17:19 PDT
Comment on attachment 201544 [details]
Another update

Ok.
Comment 14 WebKit Commit Bot 2013-05-14 09:16:36 PDT
Comment on attachment 201544 [details]
Another update

Clearing flags on attachment: 201544

Committed r150071: <http://trac.webkit.org/changeset/150071>
Comment 15 WebKit Commit Bot 2013-05-14 09:16:39 PDT
All reviewed patches have been landed.  Closing bug.