I am experiencing a similar issue with other things. I haven’t tried editing quiz questions, but the scenario being described is close enough that Ron ( @Ron_Bowman ) pointed this thread out to me (twice). The first time I didn’t see the similarity as much, but now I definitely do
My problem was with QuizWiz. It’s a userscript I shared that speeds up SpeedGrader and classic quizzes within SpeedGrader. It has been working pretty flawlessly (other than choosing a bad CDN provider) for about 5.5 years years without any major changes. Last week, a couple of people said that it stopped working.
What stopped working was the quiz side of things. The SpeedGrader enhancements still work, but the parts that enhance classic quizzes stopped. More specifically, it stopped working after the first student. It would work for the first student but then not.
I spent a lot of time this weekend researching the problem. Although both are related to classic quizzes, I don’t think classic quizzes is the issue. What I think is the issue is that they both have event listeners within an iframe. Mine are when buttons are clicked, but the Rich Content Editor that allows you to edit the HTML question is inside an iframe as well.
I did a major rewrite of QuizWiz over the past few days. I removed all of the lint problems that showed up, refactored complex code into simpler functions, switched from using var to const and let, used arrow functions when possible, etc. None of that fixed the issues.
I’m seeing the problem in every browser (people originally thought it was related to the Chrome update), but not every browser simultaneously breaks at the same time. That strongly suggests that it is something that Canvas did. But classic quizzes aren’t being developed anymore, so what could they do that would so drastically break things?
In my testing, I noticed that Canvas is now using Sentry. That’s a recent change, probably about the time this started happening. From what I can tell, it is intended to find errors in the code and report them back to Canvas with enough information that they can hopefully figure out what is going on. If you open the developer tools in your browser and look at the network tab, you will now notice a sentry_entry that wasn’t there prior to these problems.
One of the things that Sentry does is replace the addEventListener with their own code. When someone adds an event listener, it intercepts the call so that their code is called. If you open the developer tools console and type addEventListener, you’ll see what I’m talking about. The small portion of the code that is shown first checks to see if the event is a click or keypress. All of the buttons that I add are click events and many things in the RCE would be click or keypress.
In theory, this shouldn’t cause any problems because our event listener is still called. In theory, it should be great for Canvas because now they can see when problems happen, rather than having to rely on users to report them.
Theory isn’t reality, though. Any errors in third party code are now silent. If I mistyped a keyword, it used to throw a big error message in the console letting me know. Now, that gets captured by Sentry so I cannot see what it is. It makes developing our custom JavaScript harder without those messages.
Then there is the whole iframe issue. My event listeners in the main Canvas page do work. It’s the ones that are in iframes (the RCE or the classic quizzes in SpeedGrader) that do not work. They work correctly the first time, but when the iframe is reloaded (moving to another student or opening a new RCE) and the listeners are re-added, they don’t work.
I cannot say with certainty that Sentry is the culprit, but everything I’m seeing and what people are writing here is consistent with that being the cause. It is global across browsers (I haven’t checked Safari). It affects iframes. It works right once but not after that. It only recently started happening.
My current working theory is that something about Sentry and iframes is broken. It's not classic quizzes, it's not the Rich Content Editor. Focusing on those things is wasting time.
I didn’t see anything in the release notes about sentry being deployed (granted, I may have just missed it). It’s not forward-facing, it doesn’t change the desired behaviors, so they shouldn’t need to tell us about it. Except that it is a very invasive and major change that has the potential to break a lot of everything because it takes over the browser’s addEventListener completely.
In some ways, seeing that other people are having issues with iframes is a relief. While I’m sad other people are having problems, it means that it might not be my code was broken. That means that I can stop staying up all night trying to fix it and work on other things.