instructure / canvas-lms

The open LMS by Instructure, Inc.
https://github.com/instructure/canvas-lms/wiki
GNU Affero General Public License v3.0
5.58k stars 2.48k forks source link

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

Open H4ad opened 2 years ago

H4ad commented 2 years ago

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:

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

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.

bweston6 commented 2 years ago

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.

zack466 commented 2 years ago

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.

jonespm commented 2 years ago

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.