Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

fix($$RAFProvider): check for webkitCancelRequestAnimationFrame. #6542

Closed
wants to merge 1 commit into from

Conversation

Traxmaxx
Copy link
Contributor

@Traxmaxx Traxmaxx commented Mar 4, 2014

Request Type: bug

How to reproduce: Use AngularJS 1.2.14 together with ngAnimate in Cordova/PhoneGap WebView on Android 4.3

Component(s): ngAnimate

Impact: small

Complexity: small

This issue is related to:

Detailed Description:

RAFProvider is checking for cancelAnimationFrame and webkitCancelAnimationFrame ( see

var cancelAnimationFrame = $window.cancelAnimationFrame ||
)
For Android 4.3 we need to check for webkitCancelRequestAnimationFrame too, otherwise the animations will fail.

Other Comments:

No breaking changes, closes #6526

@mary-poppins
Copy link

Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.

  • Uses the issue template (#6542)

If you need to make changes to your pull request, you can update the commit with git commit --amend.
Then, update the pull request with git push -f.

Thanks again for your help!

@tbosch
Copy link
Contributor

tbosch commented Mar 6, 2014

Hi,
thanks for the PR. Could you also create a unit test for this?

@tbosch tbosch added this to the 1.3.x milestone Mar 6, 2014
@tbosch tbosch removed their assignment Mar 6, 2014
@Traxmaxx
Copy link
Contributor Author

Traxmaxx commented Mar 6, 2014

Heya,
I assumed it's already covered by https://github.com/angular/angular.js/blob/master/test/ng/rafSpec.js and took a closer look today. Tests for the different rAF APIs is indeed missing.

I'm currently facing problems on how to test the different rAF implementations. I started with adding a spy like that:

beforeEach(module(function($provide) {
  $provide.value('$window', {
    requestAnimationFrame: jasmine.createSpy('$window.requestAnimationFrame')
  });
}));

but expect($window.requestAnimationFrame).toHaveBeenCalled; is always passing, even when it should fail. Do you have a idea what I'm missing?

@quantizor
Copy link

Is there an Android browser included in the E2E tests? Otherwise the situation where it is needed would not arise. I don't see one listed: https://github.com/angular/angular.js/blob/master/karma-shared.conf.js

@caitp
Copy link
Contributor

caitp commented Mar 6, 2014

We don't, but it looks like SL will let us test on a couple of more recent android platforms, and some iOS platforms, so it should be easy to hook those in. Want to analyze the costs and send a PR with the configuration changes and that info? Or maybe it would be better if someone internal looked at doing that (or maybe for 1.x we just don't care, but we'll probably want this for 2.x)

@quantizor
Copy link

Sure thing!

@quantizor
Copy link

PR opened #6578

@tbosch
Copy link
Contributor

tbosch commented Mar 6, 2014

@Traxmaxx The problem is that angular-mocks contains a mock implementation of $$rAF.

For $httpBackend we have the same problem (there is a mock implementation and a real one). To test the real one, src/ng/httpBackend.js defines a top level function createHttpBackend that is used in the tests to create the real instance.

Applying this to rAF: Add a top level function createRAF($window) in src/ng/raf.js and make the provider use that function as well. Then call createRAFin your unit test to create the real rAF service and pass in your fake window.

E.g. change src/ng/raf.js like this:
function $$RAFProvider(){ //rAF this.$get = ['$window', createRAF]; } function createRAF($window) { var requestAnimationFrame = $window.requestAnimationFrame || $window.webkitRequestAnimationFrame; ... }

Note that this is working as during the unit tests of Angular we don't add the surrounding function closure of Angular, so unit tests are able to access all the details of Angular.

@Traxmaxx
Copy link
Contributor Author

Traxmaxx commented Mar 6, 2014

@tbosch thanks for the detailed explanation : )
I made the changes and added a unit test for the Android fallback.

@matsko
Copy link
Contributor

matsko commented Mar 14, 2014

@Traxmaxx could you copy the test spec from here? This way you don't have to rewrite raf.js and expose a function name. Look at the test code, it creates a custom injector to work around the ngMock defaults: matsko@3439ca6

@Traxmaxx
Copy link
Contributor Author

Of course! I'll take care of it.

@matsko
Copy link
Contributor

matsko commented Mar 18, 2014

@Traxmaxx any progress?

Android 4.3 only supports webkitCancelRequestAnimationFrame.

Closes angular#6526
@Traxmaxx
Copy link
Contributor Author

@matsko fixed and pushed : )

@matsko
Copy link
Contributor

matsko commented Mar 19, 2014

MERGED

@matsko
Copy link
Contributor

matsko commented Mar 19, 2014

Landed as c839f78 and e84da22

@matsko matsko closed this Mar 19, 2014
@Traxmaxx Traxmaxx deleted the android-raf branch March 19, 2014 10:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ng-animate 1.2.14 bug on android
6 participants