New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API] __Zone_disable_RequestAnimationFrame #875

Closed
Jinkwon opened this Issue Aug 16, 2017 · 6 comments

Comments

Projects
None yet
3 participants
@Jinkwon

Jinkwon commented Aug 16, 2017

We use webgl with zone.js.
requestAnimationFrame monkey patching makes perf issue from zone.js.
We need api such as __Zone_disable_RequestAnimationFrame = true;.

I found some flag on/off api from the modules page here.
Someone has any idea at all? ;)

Modules

https://github.com/angular/zone.js/blob/b3a76d3f8d374be8edf009f7a077e51eefec6a65/MODULE.md

@JiaLiPassion

This comment has been minimized.

Collaborator

JiaLiPassion commented Aug 16, 2017

there are 2 solutions.

  1. I can make a change to let __Zone_disable_RequestAnimationFrame = false disable requestAnimationFrame patching.

  2. you can try to do this one, this will still have some overhead.

Zone.current.fork({
name: 'disableRequestAnimationFrame',
onScheduleTask: function(delegate, curr, target, task) {
if (task.source.contains('AnimationFrame') {
task.cancelScheduleRequest();
return Zone.root.scheduleTask(task);
}
return delegate.scheduleTask(target, task);
}
});

please try this one, if this still does not match your performance requirement, please let me know.

@Jinkwon

This comment has been minimized.

Jinkwon commented Aug 16, 2017

@JiaLiPassion Thanks for your feedback.

In my case, 1st solution is nice.
I solved issue with some my bad codes.
But if zone.js support api, it will be better though.

My code is here.

// rollback my honey monkey
if (window.__zone_symbol__requestAnimationFrame) {
  window.requestAnimationFrame = window.__zone_symbol__requestAnimationFrame;
  window.cancelAnimationFrame = window.__zone_symbol__cancelAnimationFrame;
  window.webkitRequestAnimationFrame = window.__zone_symbol__webkitRequestAnimationFrame;
}

JiaLiPassion added a commit to JiaLiPassion/zone.js that referenced this issue Aug 16, 2017

@JiaLiPassion

This comment has been minimized.

Collaborator

JiaLiPassion commented Aug 16, 2017

I have made a PR #876, you can use __Zone_disable_requestAnimationFrame = true to disable requestAnimationFrame patch.

@iamdenny

This comment has been minimized.

iamdenny commented Aug 16, 2017

also need to disable about webworker.
because mapbox.js use webworker a lot when use requestAnimation.
specially slow when use onmessage, so I change the code like this.

window.onmessage = window.__zone_symbol___onmessage;

Please make __Zone_disable_webworker or __Zone_disable_worker
Thanks.

@JiaLiPassion

This comment has been minimized.

Collaborator

JiaLiPassion commented Aug 16, 2017

@iamdenny , in your case, you just want to disable patching window.onmessage?

@iamdenny

This comment has been minimized.

iamdenny commented Aug 16, 2017

webworker use postMessage and onmessage

JiaLiPassion added a commit to JiaLiPassion/zone.js that referenced this issue Aug 16, 2017

@mhevery mhevery closed this in fcf187c Aug 23, 2017

mhevery added a commit that referenced this issue Aug 23, 2017

feat(onProperty): fix #875, can disable patch specified onProperties (#…
…877)

* feat(onProperty): fix #875, can disable patch specified onProperties

* update module.md

* export interface

* add prototype init

* add test fake polyfill to karma.dist config

* remove console.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment