Image Component: Cropped Images Disappearing | Community
Skip to main content
JonMaguire
New Participant
December 22, 2020
Solved

Image Component: Cropped Images Disappearing

  • December 22, 2020
  • 1 reply
  • 2015 views

When our authors use the cropping option in the Image Component, the image "disappears" like this.

This seems to happen with larger images.  For example, the original image size I'm testing is 6582x4388.

We are using AEM 6.5 and components version 2.13.0.

I haven't found any useful info in the logs, but I'm not sure what I'm looking for.

I'm wondering if this has happened to others and how you may have resolved it?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Kunal_Gaba_

Yes I was able to replicate this issue on my local environment as well. I did some debugging and looks like it has nothing to do with crop function. Below are my findings- 

  1. When you crop an image the inline image editor finishes and the component is reloaded async.
  2. The core Image component uses lazy loading and it just sets the new cropped image uri in src attribute of image element as part of load event. However, I see that it fires multiple image request calls. May be because of lazy loading and window resize and viewport enter events. 
  3. The image URL is served by core components Adaptive Image servlet - https://github.com/adobe/aem-core-wcm-components/blob/f11e666718ece32b46a090e4c333dac17fd85094/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/servlets/AdaptiveImageServlet.java#L91
  4.  And interestingly if you manually trigger multiple calls from your browser by hitting the image URL again and again then you will notice that the component returns Out of memory error. (Ex - http://localhost:4502/content/we-retail/us/en/about-us/jcr%3acontent/root/responsivegrid/tabs/item_1/image.coreimg.82.1024.jpeg/1608695352751.jpeg

 

      5. Further I looked at the AdaptiveImageServlet code and found that it loads the image in memory, transforms image in memory and then streams it. 

 

So  my guess is that when you have big size images then AdaptiveImageServlet might not be able to function as expected. As it loads the image in memory for processing and might eat up your heap size. And you see this issue more often during crop because just after crop finishes it fires multiple calls to load the image. 

1 reply

Kunal_Gaba_
Kunal_Gaba_Accepted solution
New Participant
December 23, 2020

Yes I was able to replicate this issue on my local environment as well. I did some debugging and looks like it has nothing to do with crop function. Below are my findings- 

  1. When you crop an image the inline image editor finishes and the component is reloaded async.
  2. The core Image component uses lazy loading and it just sets the new cropped image uri in src attribute of image element as part of load event. However, I see that it fires multiple image request calls. May be because of lazy loading and window resize and viewport enter events. 
  3. The image URL is served by core components Adaptive Image servlet - https://github.com/adobe/aem-core-wcm-components/blob/f11e666718ece32b46a090e4c333dac17fd85094/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/servlets/AdaptiveImageServlet.java#L91
  4.  And interestingly if you manually trigger multiple calls from your browser by hitting the image URL again and again then you will notice that the component returns Out of memory error. (Ex - http://localhost:4502/content/we-retail/us/en/about-us/jcr%3acontent/root/responsivegrid/tabs/item_1/image.coreimg.82.1024.jpeg/1608695352751.jpeg

 

      5. Further I looked at the AdaptiveImageServlet code and found that it loads the image in memory, transforms image in memory and then streams it. 

 

So  my guess is that when you have big size images then AdaptiveImageServlet might not be able to function as expected. As it loads the image in memory for processing and might eat up your heap size. And you see this issue more often during crop because just after crop finishes it fires multiple calls to load the image. 

JonMaguire
New Participant
December 23, 2020
Thanks for the explanation, it is helpful. I did notice that the default max size of 3840 can be increased in the Web Console, so I increased it to 7000 just to test. I'm not sure almost doubling this value is the best way to go about this, but it did resolve the issue.