Unexpected Image Animator Threads
Client report high cpu utilization: https://my.dotcms.com/tickets/detail.dot?id=43ecef4e-62bb-4093-a6e8-48388f0b196f
After reviewing their thread dumps, it appears that there were two image animator threads that are in a runnable state and since they are running on a 4 cpu box, that could account for the 50% minimum cpu utilization they were seeing.
I have not been able to totally reproduce these threads being in constant runnable state but I am able to produce these extra threads by uploading animated gifs into dotcms. For every animated gif I upload, I end up with another "Image Animator" thread.
For example, I uploaded three animated gifs from: http://giphy.com/search/animated-gif For each gif I uploaded, I ended up with an animator thread. So, after my three uploads, I have these three threads:
"Image Animator 3" #419 daemon prio=3 os_prio=0 tid=0x00007f1218092000 nid=0x10be sleeping[0x00007f11be8c0000]
java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep(Native Method)
at sun.awt.image.GifFrame.dispose(GifImageDecoder.java:670)
at sun.awt.image.GifImageDecoder.readImage(GifImageDecoder.java:458)
at sun.awt.image.GifImageDecoder.produceImage(GifImageDecoder.java:212)
at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:269)
at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:205)
at sun.awt.image.ImageFetcher.run(ImageFetcher.java:169)
Locked ownable synchronizers:
- None
"Image Animator 3" #415 daemon prio=3 os_prio=0 tid=0x00007f1208444800 nid=0xfaa sleeping[0x00007f11be9c1000]
java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep(Native Method)
at sun.awt.image.GifFrame.dispose(GifImageDecoder.java:670)
at sun.awt.image.GifImageDecoder.readImage(GifImageDecoder.java:458)
at sun.awt.image.GifImageDecoder.produceImage(GifImageDecoder.java:212)
at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:269)
at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:205)
at sun.awt.image.ImageFetcher.run(ImageFetcher.java:169)
Locked ownable synchronizers:
- None
"Image Animator 3" #407 daemon prio=3 os_prio=0 tid=0x00007f12083a4800 nid=0xf0e sleeping[0x00007f11bf0c6000]
java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep(Native Method)
at sun.awt.image.GifFrame.dispose(GifImageDecoder.java:670)
at sun.awt.image.GifImageDecoder.readImage(GifImageDecoder.java:458)
at sun.awt.image.GifImageDecoder.produceImage(GifImageDecoder.java:212)
at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:269)
at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:205)
at sun.awt.image.ImageFetcher.run(ImageFetcher.java:169)
Locked ownable synchronizers:
- None
Yeah, I tried a few things out and this one is a little weird.
- I uploaded an animated GIF to demo and saved it (without publishing it), and dotCMS created a new "Image Animator 3" thread in
TIMED_WAITING (sleeping)state. - I then saved that image file, the image animator thread changed to
RUNNABLE (sleeping)state. - I then added a piece of content (Promotion) that references that image in an Image field:
- Two more threads with the same name ("Image Animator 3") were created.
- The original thread changed back to
TIMED_WAITING (sleeping)state. - One of the new threads was in
RUNNABLE (sleeping)state, and the other was inTIMED_WAITING (sleeping)state.
- After adding the Promotion to a page, one of the 2 new threads changed to
TIMED_WAITINGstate (no(sleeping)). - After viewing the page on the front end, all 3 of the "Image Animator 3" threads changed back to
TIMED_WAITING (sleeping)state.
Seems like a thread should only be created for an animated GIF if it's currently being displayed - not when it gets uploaded to the system. (And even then, should we be animating this within dotCMS, or just sending the image to the user's browser to animate it?).
But even when I display the image on the front end, the image isn't actually being animated, and the threads don't go into running state.
Feels like a bug. Maybe with Tika trying to parse the animated GIF's metadata when it gets uploaded?
yeah, pretty sure someone is making a call to a jdk class that is spawning these threads that are not needed for what we are doing with the files and never seem to get cleaned up even after I flush cache, etc.
This was observed again on a different client: https://my.dotcms.com/tickets/detail.dot?id=fd40cee2-18f0-4cd7-ad84-bd96d0f82978
This issue has been automatically marked as stale because it has not had activity within the past 90 days. It will be closed in 30 days no further activity occurs. Thank you.