ohshi000 / androidsvg

Automatically exported from code.google.com/p/androidsvg
0 stars 0 forks source link

Sometimes uncorrectly loads embeded images #25

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Load attached "test1.svg" in SVGImageView. 

What is the expected output? What do you see instead?
It contains three embeded pngs. Opening this svg in IE9 shows embeded pngs 
correctly any time i load svg.
What i see:
Sometimes after rendering images, i see "trashed" images instead of real. 

What version of the product are you using? On what operating system?
1.2.0.
OS: Android 4.1.2.
Hardware Galaxy Note 10.1 (2012 year)

Original issue reported on code.google.com by shumi.ar...@gmail.com on 17 Dec 2013 at 10:07

GoogleCodeExporter commented 8 years ago

Original comment by shumi.ar...@gmail.com on 17 Dec 2013 at 10:36

Attachments:

GoogleCodeExporter commented 8 years ago
Screenshot with ok load

Original comment by shumi.ar...@gmail.com on 17 Dec 2013 at 10:37

Attachments:

GoogleCodeExporter commented 8 years ago
Screenshot where part of first embeded image is badly loaded (it is similar 
when something loading from cache)

Original comment by shumi.ar...@gmail.com on 17 Dec 2013 at 10:38

Attachments:

GoogleCodeExporter commented 8 years ago
Screenshot where all embeded images were loaded "trashed"

Original comment by shumi.ar...@gmail.com on 17 Dec 2013 at 10:38

Attachments:

GoogleCodeExporter commented 8 years ago
Hi. Thanks for the report.

How often does this happen?  Are you able to reproduce it reliably?

Original comment by paul.leb...@gmail.com on 17 Dec 2013 at 12:14

GoogleCodeExporter commented 8 years ago
This happens almost any rendering time.

As I understand this effect happens first of all with big embeded images (from 
10 KB - in attached svg size is approximately 60 KB), because with small images 
it works fine.

I'll try to record small video at post it here.

Original comment by shumi.ar...@gmail.com on 17 Dec 2013 at 12:54

GoogleCodeExporter commented 8 years ago
When you say "embedded images", do you mean data-url/Base64 images?  Does it 
happen if the images are external to the SVG file?

Original comment by paul.leb...@gmail.com on 17 Dec 2013 at 12:57

GoogleCodeExporter commented 8 years ago
Saying "embedded images" I mean images with href like this:
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJkAAAC3CAIAAACOmGurAAAAA3NCSVQIC
Ajb4U/gAAAgAElEQVR4 nIy92bcmx5..."

I didn't try to use external to SVG images, so I cann't say anything about this 
case.

Original comment by shumi.ar...@gmail.com on 17 Dec 2013 at 1:21

GoogleCodeExporter commented 8 years ago
Paul, hello!

Do you have any ideas: how to solve the problem?

Original comment by shumi.ar...@gmail.com on 23 Dec 2013 at 6:28

GoogleCodeExporter commented 8 years ago
Paul, hello again!

All my investigations and analysis of situation with embedded images resulted 
in:
problem is in this code line of SvgAndroidRenderer:
canvas.drawBitmap(image, 0, 0, state.fillPaint);

I decided to replace it with:
state.fillPaint.setColor(0xFFFFFF00); //yellow color
canvas.drawRectangle(obj.boundingBox.toRectF(), state.fillPaint);

And everything is good.
But drawBitmap doesnot work at all.

At the same time I tested this bug on HTC One S (OS version 4.1.1) - result is: 
the same situation. Some items are drawn as expected, some are drawn as trash.

Original comment by shumi.ar...@gmail.com on 23 Dec 2013 at 8:16

GoogleCodeExporter commented 8 years ago
Ah yes.  I remember now.  This is the same issue that I noticed and fixed a 
couple of months ago.

The fix will be in the next release (1.3) which should be released earlier 
2014.  Unfortunately I can't commit a fix to the repository right now, but if 
you change line 1838 to:

canvas.drawBitmap(image, 0, 0, new Paint());

things should work a lot better.

Let me know if this does work.  Thanks for the work you have done investigating 
this issue.

Original comment by paul.leb...@gmail.com on 23 Dec 2013 at 9:31

GoogleCodeExporter commented 8 years ago
Paul, thanks a lot.

But unfortunately there is no result.
The same problems exist.

Now I'll try to use external to SVG images.

Original comment by shumi.ar...@gmail.com on 23 Dec 2013 at 10:40

GoogleCodeExporter commented 8 years ago
As I expected, the same results for images external to SVG. Some are drawn 
correctly, some no.

Paul, during investingating found out that after drawing bitmap it is necessary 
to mark bitmap as recycled, so I recommend you to add one more change:

canvas.drawBitmap(image, 0, 0, new Paint());
image.recycle(); //mark as recycled

And once more change that I saw in the origin library (svg-android): before 
drawing bitmap the author prepares image to be drawn using following line:
image.prepareToDraw();

So the result code is:
image.prepareToDraw();
canvas.drawBitmap(image, 0, 0, new Paint());
image.recycle();

Original comment by shumi.ar...@gmail.com on 23 Dec 2013 at 11:34

GoogleCodeExporter commented 8 years ago
Marking as "recycled" need to inform GC about possibility to remove bitmap from 
heap.

Original comment by shumi.ar...@gmail.com on 23 Dec 2013 at 11:35

GoogleCodeExporter commented 8 years ago
Paul, hello again!

I've create small class PhantomView.
It has list of string - paths to images at internalSD memory (like using 
external to SVG images).

Override onDraw method and tried to see the result of drawing approximately 10 
images.
Everithing is OK!

So the problem lies somewhere else.

Original comment by shumi.ar...@gmail.com on 23 Dec 2013 at 1:06

Attachments:

GoogleCodeExporter commented 8 years ago
Could you fix it please?

Original comment by dtambore...@gmail.com on 11 May 2014 at 9:47

GoogleCodeExporter commented 8 years ago
This fix will be available in 1.2.2.  A beta release of 1.2.2 is now available 
on the downloads page.

Marking Fixed.

Original comment by paul.leb...@gmail.com on 16 Jun 2014 at 7:47