U4-5304 - 7.1.4 Media Picker can't view images RangeError: Maximum call stack size exceeded

Created by Mark Bowser 01 Aug 2014, 18:42:14 Updated by Shannon Deminick 08 Aug 2014, 17:32:57

Is duplicated by: U4-5315

Relates to: U4-5315

Relates to: U4-4634

This issue is similar to but different than this issue http://issues.umbraco.org/issue/U4-4771.

RangeError: Maximum call stack size exceeded at Function._.min (http://MyUmbracoSite/umbraco/lib/underscore/underscore.js:266:5) at Object.getMaxScaleableHeight (http://MyUmbracoSite/umbraco/js/umbraco.services.js:7162:36) at Object.getRowHeightForImages (http://MyUmbracoSite/umbraco/js/umbraco.services.js:7016:43) at Object.getRowHeightForImages (http://MyUmbracoSite/umbraco/js/umbraco.services.js:7078:29) at Object.getRowHeightForImages (http://MyUmbracoSite/umbraco/js/umbraco.services.js:7031:37) at Object.getRowHeightForImages (http://MyUmbracoSite/umbraco/js/umbraco.services.js:7078:29) at Object.getRowHeightForImages (http://MyUmbracoSite/umbraco/js/umbraco.services.js:7031:37) at Object.getRowHeightForImages (http://MyUmbracoSite/umbraco/js/umbraco.services.js:7078:29) at Object.getRowHeightForImages (http://MyUmbracoSite/umbraco/js/umbraco.services.js:7031:37) at Object.getRowHeightForImages (http://MyUmbracoSite/umbraco/js/umbraco.services.js:7078:29)

I can view the media in the media section, but I can't expand the sub folder in the media pickers. I'm not sure which image is a problem. There are 58 images under the sub folder. What sorts of images do you think would cause this problem? Very tall or very wide ones?

I dug around in the angular source and found the umbraco/js/umbraco.services.js file. It has a function called getRowHeightForImages. This function recurses infinitely. In my screen shot I showed where the infinite recursion occurs. The function things it will "generate a new targetHeight that is halfway between the max and the current and recurse, passing in a new targetHeight". However, the maxRowHeight is equal to the targetHeight, so the targetHeight never increases and we recurse forever.

I've been too busy to figure out what this code is actually doing so far. Anyone have a fix?

1 Attachments


Mark Bowser 05 Aug 2014, 15:31:19

I've temporarily hacked this so the client can continue to enter content for a while. I just threw this in. Doesn't work all the time and is probably just sweeping the real problem under the bed.

var oldTargetHeight = targetHeight; targetHeight += Math.floor((maxRowHeight - targetHeight) / 2); if(targetHeight == oldTargetHeight){ targetHeight += 25; }

Mark Bowser 05 Aug 2014, 15:42:04

Here are the image dimensions in the sub directory in order widthxheight: 1000x933 1000x1005 1000x1261 1000x608 2000x2571 907x674 1000x680 1000x710 1000x636 1000x886 1000x683 1000x460 1000x690 1000x711 1000x831 1000x532 1000x1100 1000x681 1000x593 1000x809 974x1261 1000x789 1000x1128 1000x1507 967x608 1000x818 1000x760 980x808 1000x654 1000x1014 1000x769 491x354 1094x821 1000x811 1000x1135 1000x1041 1000x2013 840x360 544x378 1000x1110 1000x727 640x557 1000x586 630x421 1000x367 1000x639 1000x1100 784x332 650x606 1000x612 820x586 1000x442 1000x666 1000x802 1000x835 1000x1071 1000x1286 1000x1286

Shannon Deminick 05 Aug 2014, 20:07:10

Thanks mark, i have a test reproducing this now. Just need to nail it down.

Shannon Deminick 06 Aug 2014, 17:19:41

This is fixed in rev: fc19748fbfad3431f30478e6c5a944b803fc9f59 have added a test too.

The problem is just this combination of sizes:

1000x1041 1000x2013 840x360

Here's the attempted 'english' version of the logic:

  • Tries to fit 3 (ideal img count) images into the width, but with the scaling they come up too short (height) based on the minDisplayHeight
  • Removes an image for the row
  • Try to scale up the images (to maxRowHeight) to fit 2 images into the width, but they come up too narrow based on the maxRowHeight
  • We now know that fitting these 3 or two images is just not possible based on the size constraints
  • We have 2 images and the targetHeight === maxRowHeight, we should just display them. So we'll render a row that will be max height but won't be wide enough which is better than rendering a row that is shorter than the minimum since that could be quite small.

Mark Bowser 06 Aug 2014, 17:37:17


Priority: Normal

Type: Bug

State: Fixed

Assignee: Shannon Deminick

Difficulty: Normal


Backwards Compatible: True

Fix Submitted:

Affected versions:

Due in version: 7.1.5


Story Points: