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

"This webpage was reloaded because it was using significant memory." #43

Open
martinmts opened this issue Aug 5, 2021 · 4 comments
Open

Comments

@martinmts
Copy link

Hi James,

I have QuizWiz: Standalone. When I use it on the grading page, it shows:

This webpage was reloaded because it was using significant memory.
image

Any way to find out what is causing it?

I had edited the autoExpandeComment section:

	  function autoExpandComments() {
		if (typeof config.autoExpandComments !== 'undefined' && !config.autoExpandComments) {
		  return;
		}
		var nodes = D.querySelectorAll('div#questions > div.question_holder > div.display_question > div.quiz_comment');
		for (var i = 0; i < nodes.length; i++) {
		  var t = nodes[i].querySelector('textarea');
		  if (t) {
			if (t.value.length > 0) {
			  resizeComment(t);
			}
			t.addEventListener('input', watchComment, false);
			t.addEventListener('paste', pasteComment, false);
		  }
		}
	  }
  
	  function pasteComment(e) {
		if (e.target.value.length === 0) {
		  var divElement = e.target.parentNode;
		  divElement.style.display = 'block';
		  e.target.style.width = '98%';
		  e.style.height = '40px';
		}
	  }
  
	  function watchComment(e) {
		if (e.target.value.length >= 1) {
		  resizeComment(e.target);
		} else {
		  e.target.style.height = '40px';
		}
	  }
  
	  function resizeComment(e) {
		var divElement = e.parentNode;
		if (e.value.length > 0) {
		  divElement.style.display = 'block';
		  e.style.width = '98%';
		 // e.style.height = '40px';
		  e.style.height = (e.scrollHeight)+"px";
		} else {
		  divElement.style.display = 'inline-block';
		  e.style.width = 'auto';
		  e.style.height = '40px';

		}
	  }

And this is my setting:

	var config = {
	  // Regrading methods may be 'disabled', 'enabled', or 'autorun'
	  'methods' : {
		'unanswered' : 'autorun',
		'full_points' : 'autorun',
		'ma_allnone' : 'disabled',
		'ma_correct' : 'disabled',
		'ma_difference' : 'disabled',
		'fill_in_blanks' : 'disabled',
		'dropdowns' : 'disabled'
	  },
	  // Speed enhancements may be true or false
	  'autoExpandComments' : true,
	  'duplicateQuestionHeader' : true,
	  'showButtonCounts' : true,
	  'nextAfterUpdate' : true,
	  'nextAfterComment' : true,
	  'nextAfterRubric' : true,
	  'nextRubricExpanded' : true
	};
  
	var QuizWiz = function(config) {
	  'use strict';
	  if (typeof config === 'undefined') {
		// Each regrading method has three possible options:
		// disabled -- do not use this method
		// enabled -- use this method
		// autorun -- use this method and automatically run it
		config = {
		  'methods' : {
			'unanswered' : 'autorun',
			'full_points' : 'disabled',
			'ma_allnone' : 'disabled',
			'ma_correct' : 'disabled',
			'ma_difference' : 'disabled',
			'fill_in_blanks' : 'disabled',
			'dropdowns' : 'disabled'
		  },
		  // Speed enhancements may be true or false
		  'autoExpandComments' : true,
		  'duplicateQuestionHeader' : true,
		  'showButtonCounts' : true,
		  'nextAfterUpdate' : false,
		  'nextAfterComment' : false,
		  'nextAfterRubric' : false,
		  'nextRubricExpanded' : false
		};
	  }

Thanks!

@jamesjonesmath
Copy link
Owner

The scrollHeight seems to be the only questionable deviation from what I had. In no particular order: Does it still happen if you go back to your fixed height of 40px (the line above it that is commented out)? Is it consistently reproduceable? Does it happen with my original script? Does it happen with the script disabled? Do you have other scripts running on the page -- if so disable them, I did document that there should only be one version of QuizWiz running.

A quick search for your error message suggests that it's specific to Safari and it happens on many pages that have endless scrolling content or lots of streaming content (stocks, gmail, facebook) and not necessarily related to the amount of memory you have. Many of the people were using the new M1 chip, so it's not like they had old machines. Suggestions from the Reddit thread were to use a different browser. Other places (for a related error message) suggested closing other tabs.

I don't know how big your quizzes are, how many students there are in your course, or anything else. I would check the things at the top first.

@martinmts
Copy link
Author

Thanks, James, for your quick reply.

Is it consistently reproduceable? Does it happen with my original script? Does it happen with the script disabled? Do you have other scripts running on the page -- if so disable them, I did document that there should only be one version of QuizWiz running.

I do have other scripts, but only one QuizWiz is running. I'll disable others next time and see if it helps.
Safari will complain about it after some random period of time when I enable the QuizWiz script. When I disable it, it will not complain.

Does it still happen if you go back to your fixed height of 40px (the line above it that is commented out)?

Most of the time, I did not need to touch the comment boxes at all when I grade. Therefore, the functions related to the comment boxes are not even executed. However, I'll give a try next time to see if helps.

A quick search for your error message suggests that it's specific to Safari and it happens on many pages that have endless scrolling content or lots of streaming content (stocks, gmail, facebook) and not necessarily related to the amount of memory you have. Many of the people were using the new M1 chip, so it's not like they had old machines. Suggestions from the Reddit thread were to use a different browser. Other places (for a related error message) suggested closing other tabs.

It's probably only Safari is designed to report higher memory use. It's not a very big problem, as everything seems to work fine, except perhaps the loading is slowed down a bit. If I can't find a solution, I'll switch to another browser then.

I don't know how big your quizzes are, how many students there are in your course, or anything else. I would check the things at the top first.

My quizzes have around 20-25 questions, and only 3-4 questions needs manual grading. All others are match questions, multiple choice, and T/F questions. Therefore, the size of the quizzes does not seem to be a problem.

I have finished grading. Next time, I'll try the original QuizWiz script and disable all others and see if this issue still comes up.
I'll update then.

Thanks again!

@martinmts
Copy link
Author

Hi James,

I disabled all user scripts and enabled only the Stand Alone QuizWit script.
I changed only the first two options to "autorun". I'm still getting this after a few minutes:
image

The quiz I was grading has 22 questions, only three short essay questions and require only one line of answer, about 10 words. All other questions are matching, multiple choice or T/F questions.

  var config = {
    // Regrading methods may be 'disabled', 'enabled', or 'autorun'
    'methods' : {
      'unanswered' : 'autorun',
      'full_points' : 'autorun',
      'ma_allnone' : 'disabled',
      'ma_correct' : 'disabled',
      'ma_difference' : 'disabled',
      'fill_in_blanks' : 'disabled',
      'dropdowns' : 'disabled'
    },
    // Speed enhancements may be true or false
    'autoExpandComments' : true,
    'duplicateQuestionHeader' : true,
    'showButtonCounts' : true,
    'nextAfterUpdate' : true,
    'nextAfterComment' : true,
    'nextAfterRubric' : true,
    'nextRubricExpanded' : true
  };

I checked the Activity Monitor. Safari does not seem to use more than usual CPU or Memory resources. So it should be a big issue. I may perhaps switch to another browser.

@martinmts
Copy link
Author

An interesting phenomenon:
When I use the same user script in Microsoft Edge, CPU immediately goes to 70+% and the fan spins crazily.
I use the same user script in Vivaldi, it behaves normally.

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