Skip to content
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

Angular : Page frozen when recording and then hovering over button with tooltip #469

Closed
ZakYahi opened this issue Jan 20, 2021 · 5 comments

Comments

@ZakYahi
Copy link

ZakYahi commented Jan 20, 2021

Hello,

When I try to record a page everything seems to record normally but when I hover a button to show a tooltip, the page freezes and becomes unresponsive.
The cpu spikes to 100 and memory usage increases.

The project is based on ngx-admin which is based on angular.

To reproduce this :

  • git clone https://github.com/akveo/ngx-admin
  • cd ngx-admin
  • git checkout c2ce881c (this is the version my project is based on, i tried the latest but does not work too)
  • npm install
  • npm i --save rrweb
  • edit src/app/pages/modal-overlays/tooltip/tooltip.component.ts so the class contains :
    • export class TooltipComponent { constructor() { record({ emit: (event) => { console.log(event); }, }); } }
  • npm run start
  • open localhost:4200
  • Navigate to Modal & Overlays > Tooltip
  • Hover any tooltip

It seems other people had the same problem but no solution or reproduction was posted (#432, #167).

Also, when I use the repl tool and point it to my link, everything works nicely.

Thanks in advance for the help!

@ZakYahi
Copy link
Author

ZakYahi commented Jan 21, 2021

Well I retried today and the repl tool is not working anymore.

@Yuyz0112
Copy link
Member

Start to debug

Now I found it will emit this event infinitely when hovering tooltip:

{"source":0,"texts":[],"attributes":[{"id":1188,"attributes":{"style":"pointer-events: auto; bottom: 643px; left: 603.547px; transform: translateY(-8px);"}},{"id":1187,"attributes":{"style":"top: 0px; left: 0px; height: 100%; width: 100%;"}}],"removes":[],"adds":[]}

@Yuyz0112
Copy link
Member

Yuyz0112 commented Jan 21, 2021

Okay, after some debugging, I can simplify the reproduce code to this basic mutation observer usage

export class TooltipComponent {
  constructor() {
    const observer = new MutationObserver(console.log);
    observer.observe(document, {
      attributes: true,
      attributeOldValue: true,
      characterData: true,
      characterDataOldValue: true,
      childList: true,
      subtree: true,
    });
  }
}

A native mutation observer can make the tooltip into a dead loop. So this is not rrweb's issue, but I'm going to check why this happened.

@Yuyz0112
Copy link
Member

Finally, I find the root cause is an Angular bug: angular/angular#26948 .

Looks like using window[window.Zone.__symbol__("MutationObserver")] to get the original MutationObserver can fix the problem, going to send a PR for that.

@ZakYahi
Copy link
Author

ZakYahi commented Jan 21, 2021

Thank you very much for the investigation!

eoghanmurray pushed a commit to statcounter/rrweb that referenced this issue Feb 3, 2021
We found Angular's zone module will patch MutationObserver which
make the browser hang in some scenarios.
Reference: angular/angular#26948
eoghanmurray pushed a commit to statcounter/rrweb that referenced this issue Feb 22, 2021
We found Angular's zone module will patch MutationObserver which
make the browser hang in some scenarios.
Reference: angular/angular#26948
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants