canvas-lms icon indicating copy to clipboard operation
canvas-lms copied to clipboard

Memory Leak in lti/jquery/messages.js when using specific chrome extensions

Open H4ad opened this issue 3 years ago • 3 comments

Summary:

I am a Facens student, which uses the domain: facens.instructure.com.

We recently faced some crash errors due to memory leaks triggered by extensions, which I describe better below.

Steps to reproduce:

  1. Make sure you have the same extensions listed at the bottom of this issue.
  2. Enter inside https://facens.instructure.com/courses/10048/assignments/86100
  3. Wait some seconds/minutes.
  4. The page will crash eventually.

Expected behavior:

The page didn't crash.

Actual behavior:

I tried to find the problem and my best tip is that it is in these lines:

https://github.com/instructure/canvas-lms/blob/2d1e01807872f474f762ed71c45975f5a2696c64/ui/shared/lti/jquery/messages.js#L84-L88

For some reason this method gets a message that it doesn't recognize and falls back inside this method.

Receiving the event looks like this:

image

This goes into a loop and starts calling again and again:

image

The performance page looked like this:

image

But, I tested using incognito mode and the performance page shows this:

image

I wait a few minutes but the page didn't crash so maybe it's related to the chrome extensions in my browser and the code inside the page not expecting to get messages from the extensions.

The extensions I have installed are:

  • https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi
  • https://chrome.google.com/webstore/detail/octotree-github-code-tree/bkhaagjahfmjljalopjnoealnfndnagc
  • https://chrome.google.com/webstore/detail/motion-devtools/mnbliiaiiflhmnndmoidhddombbmgcdk
  • https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn
  • https://chrome.google.com/webstore/detail/mermaid-diagrams/phfcghedmopjadpojhmmaffjmfiakfil
  • https://chrome.google.com/webstore/detail/json-viewer/gbmdgpbipfallnflgajpaliibnhdgobh
  • https://chrome.google.com/webstore/detail/ipfs-companion/nibjojkomfdiaoajekhjakgkdhaomnch
  • https://chrome.google.com/webstore/detail/initab/igmbdimmfbpdplpahpapkploofmgaipl
  • https://chrome.google.com/webstore/detail/google-translate/aapbdbdomjkkjkaonfhkkikfgjllcleb
  • https://chrome.google.com/webstore/detail/google-docs-offline/ghbmnnjooekpmoecnnnilnnbdlolhkhi
  • https://chrome.google.com/webstore/detail/gnome-shell-integration/gphhapmejobijbbhgpjhcjognlahblep
  • https://chrome.google.com/webstore/detail/dark-reader/eimadpbcbfnmbkopoojfekhnkhdbieeh
  • https://chrome.google.com/webstore/detail/chrome-remote-desktop/inomeogfingihgjfjlpeplalcfajhgai
  • https://chrome.google.com/webstore/detail/betterttv/ajopnjidmegmdimjlfnijceegpefgped
  • https://chrome.google.com/webstore/detail/angular-devtools/ienfalfjdbdpebioblfackkekamfmbnh

I had a friend who had the same crashes, the extensions we have in common are:

  • https://chrome.google.com/webstore/detail/angular-devtools/ienfalfjdbdpebioblfackkekamfmbnh
  • https://chrome.google.com/webstore/detail/google-translate/aapbdbdomjkkjkaonfhkkikfgjllcleb
  • https://chrome.google.com/webstore/detail/google-docs-offline/ghbmnnjooekpmoecnnnilnnbdlolhkhi
  • https://chrome.google.com/webstore/detail/dark-reader/eimadpbcbfnmbkopoojfekhnkhdbieeh
  • https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn
  • https://chrome.google.com/webstore/detail/initab/igmbdimmfbpdplpahpapkploofmgaipl

To better debug this problem, I put the Performance Profile exported from my tests below, to use, open the DevTools and go to the Performance tab and then click on the import button and select the json file.

With extensions: Profile-20220924T231038-normal-login.json.zip

Without extensions: Profile-20220924T234444-anonymous-page.json.zip

Also, the commit that may have caused this bug is: https://github.com/instructure/canvas-lms/commit/cf149e85511cc5eba85b39b1fdd3b0b5a0528534, when match when I started having the crashes.

H4ad avatar Sep 25 '22 03:09 H4ad

I'm also facing this issue in Firefox 105. Uninstalling the MetaMask extension (https://addons.mozilla.org/en-GB/firefox/addon/ether-metamask/) fixes the issue but not an ideal solution.

bweston6 avatar Sep 26 '22 13:09 bweston6

I am also facing this issue in both Firefox and Chrome. The infinite loop can be induced in either browser by simply entering window.postMessage({}) into the devtools console.

zack466 avatar Sep 27 '22 00:09 zack466

It looks like this recent commit on September 28, 2022 might be related to a possible fix https://github.com/instructure/canvas-lms/commit/1cfd7597cc31ef5bf4b6e842fddf38a88b046f02

I experienced the same with some extensions.

jonespm avatar Oct 01 '22 17:10 jonespm