This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 91942 - exporting diagram containing 50+ classes to jpg results in zero file size
Summary: exporting diagram containing 50+ classes to jpg results in zero file size
Status: VERIFIED FIXED
Alias: None
Product: uml
Classification: Unclassified
Component: Output (show other bugs)
Version: 5.x
Hardware: All Windows XP
: P2 blocker (vote)
Assignee: Viktor Lapitski
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-06 00:58 UTC by Peter Lam
Modified: 2007-03-09 22:19 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
experiment class diagram (1.60 MB, image/jpeg)
2007-01-06 01:08 UTC, Peter Lam
Details
experiment class diagram - png format (533.61 KB, text/plain)
2007-01-06 01:08 UTC, Peter Lam
Details
experiment class diagram - svg format (1.03 MB, text/plain)
2007-01-06 01:09 UTC, Peter Lam
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Lam 2007-01-06 00:58:34 UTC
This is from Windows XP so far. Have not tried on other platforms yet but
there's a known issue 82394 on exporting to jpg on linux and solaris already.
This one might be different than issue 82394 since it seems to happen on big uml
project.

- reverse engineered the UML core sources (2600+ classes)
- created class diagram from a selection of around 50 classes (consist of
classes, interfaces, derivation classifiers, packages)
- export the diagram to jpg format
Result: the jpg file has file size of zero
- if exporting a smaller class diagram containing only a few classes (just to
experiment) works fine

Another experiment:
I tried creating a new UML project. created a class diagram and manually
creating 60 classes, 20 interfaces, 20 datatypes, a few derivation classifiers,
a few packages, and different kind of links between every elements in the class
diagram. So, the class diagram contains about 110 elements. Exporting to both
jpg and svg works fine. Exporting to png file works fine too but it took about
an hour to complete while it took just seconds to export to jpg and svg format.
Comment 1 Peter Lam 2007-01-06 01:08:09 UTC
Created attachment 37101 [details]
experiment class diagram
Comment 2 Peter Lam 2007-01-06 01:08:34 UTC
Created attachment 37102 [details]
experiment class diagram - png format
Comment 3 Peter Lam 2007-01-06 01:09:09 UTC
Created attachment 37103 [details]
experiment class diagram - svg format
Comment 4 Peter Lam 2007-01-06 01:11:22 UTC
Attached are the diagrams in jpg, png, svg format exported for the experiment
with the diagram containing 110 elements.
Comment 5 Viktor Lapitski 2007-02-06 12:26:57 UTC
Png encoder performance was taken care of by fix to 91260.

The remaining part of the bug is when generated image file size is 0 (for the
reasons different from 
java.lang.ClassCastException: sun.awt.image.DataBufferNative
mentioned in 82934)

This failure to generated an image happens when size of the original image to be
encoded causes request for the amount of memory that exceeds memory availaible
inside the VM instance. It happens because the 3d party graph library used
inside the UML module atempts to render whole image in memory before encoding
it. In particular it means that 
7000 pixels x 7000 pixels image would cause a request for an int[50M] buffer,
ie. 200M piece of heap memory.
The maximum possible image is more than 50Mpixels, yet even with Xmx1280 i
wasn't always able to save 100Mpixels image.

Thus, in order to fix this bug, as we can't change the behaviour 
of the library, i plan to implement an error dialog for this situation 
explicitly informing the user that the operation failed. 
Comment 6 Viktor Lapitski 2007-02-08 03:01:36 UTC
Fixed in release55 branch.
Now when user tries to save as png/jpg/... a diagram with such resolution 
that JVM can't provide TS with an array to render the image into 
[ because of not sufficient heap memory available or because the requested array
is beyond the Java array size limit - that happens pretty 
easy - 50Kpxls X 50Kpxls = 2.5Gpxs, where is Java array limit 
is (2^31 - 1) and even 0.5Gpxls would be a problem for 32bit JVM 
as each pixels requires an "int" ] the error dialog is shown informing 
the user about the error.
Comment 7 Peter Lam 2007-02-15 09:06:48 UTC
verified in build 070213_1.
Now the error dialog pops up. The dialog has title "Cannot create image" and the
message is "Java Heap space". The message should have been more informative. 
Comment 8 Viktor Lapitski 2007-02-15 09:28:06 UTC
The message comes from the exception that was caught. This minimalistic approach
 was modeled after similar error dialog that pops up when, for example, the file
that image should be saved into isn't writtable. I suppose the documentation may
be the place where the error messages and possible remedies/workarounds can be
explained.
Comment 9 Peter Lam 2007-03-09 22:19:19 UTC
issue 96194 was opened to track the need to improve the message in the dialog
box as a result of the fix to this issue.