question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"infinite rendering invalidation detected" -- option to increase the limit or disable the check entirely

See original GitHub issue

In my ember-element-query addon I have this code:

    const _eqResizeHandler = () => {
      scheduleOnce('afterRender', this, this.eqUpdateSizes);
      next(this, this.eqUpdateSizes);
    };

    this.setProperties({_eqResizeHandler});
    window.addEventListener('resize', _eqResizeHandler, true);

It used to work flawlessly, but now resizing the browser tab causes the app to carsh with “infinite rendering invalidation detected”.

The problem happens when I’m the window for several seconds. The amount of time and movement required for the app to crash is arbitrary. Sometimes it crashes almost instantly, sometimes it takes like 10 seconds to crash.

I tried replacing next() with throttle() and increasing the timeout to unreasonably large values – and it was still crashing, so I’m not even sure that the crash is caused by this code.

These lines in ember-glimmer seem to be the cause:

let loops = 0;
function loopEnd(current, next) {
  for (let i = 0; i < renderers.length; i++) {
    if (!renderers[i]._isValid()) {
      if (loops > 10) {
        loops = 0;
        // TODO: do something better
        renderers[i].destroy();
        throw new Error('infinite rendering invalidation detected');
      }
      loops++;
      return backburner.join(null, K);
    }
  }
  loops = 0;
}

backburner.on('end', loopEnd);

I see three problems with this code:

  1. It considers an “infinite loop” to appear when there are ten loops. Ten is quite a small number and in certain use cases it is obviously not enough. For example, JS max call stack is larger than 10’000.
  2. When an “inifinite loop” is detected, this code chooses to crash the app. Why?! 😭 My addon used to work without issue and now this thing is crashing it for no reason.
  3. This code is applied in a closure, so there’s no way to override it.

I’m sure there’s perfect reasoning why such a small magic number was chosen, but:

  1. The user should be able to increase the number when his use case produces many loops.
  2. The user should be able to opt out of arbitrary crashing.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:18 (17 by maintainers)

github_iconTop GitHub Comments

4reactions
lolmauscommented, Nov 26, 2017

OK, so I’ve completely rewritten my ember-element-query addon to ensure all updates are done efficiently.

With my current implementation, element query-driven components register in a tree-like structure. Only root EQ components react to a window resize event, then they tell their children to resize, and the resize event propagates recursively from parents to children.

This ensures no component has to update more than once, i. e. once for a window resize and then once after every of its EQ parents realigns.

But the issue still happens. When EQ components are nested deep enough, the infinite rendering invalidation detected error crashes the app on continuous resize.

I was able to work around the issue by wrapping event propagation from a parent to children into run.next, but this makes event propagation noticeable to naked eye: instead of all components realigning at once, you can see how they realign sequentially. This makes native Ember implementation of element queries worse than any generic implementation.

Commenting out the error throwing line (and renderer destroying line) makes it work correctly. It seems to have no practical purpose other than putting a spoke in the wheel. 😠

Please fix it.

1reaction
pixelhandlercommented, Sep 21, 2018

@dballona thanks for the comment on using query.

@lolmaus I’m curious if you still have this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting "Uncaught Error: infinite rendering invalidation ...
With beta3 I'm getting a flash of the content followed by a white screen, but now I'm seeing the error "infinite rendering invalidation...
Read more >
Infinite rendering invalidation detected emberjs - Ember CLI
i was getting error while adding dynamic add and remove actions i am using ember v 3.0 renderer.js:167 Uncaught Error: infinite rendering ......
Read more >
Error: infinite rendering invalidation detected - Stack Overflow
Error: infinite rendering invalidation detected. Whenever I remove the closure action code, everything works fine. Route code:
Read more >
Bountysource
"infinite rendering invalidation detected" -- option to increase the limit or disable the check entirely.
Read more >
XCPT Messages - RenderMan 24 Documentation
This document lists the various warnings and errors you may encounter during rendering. You can text search to find your error.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found