You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Rolf Bruderer <ro...@zuehlke.com> on 2006/01/31 08:28:04 UTC

Problems with Driver image cache

Hello

I have another problem which seems to occur because of the same image cache as 
described in "Re:still have problems with with fo:external-graphics and rtf".

I try to generate pdf files dynamically, containing some svg-files (using
fo:external-graphics). Each time my application creates a pdf it uses the 
same FO-file for the transformation (since layout stays the same), but the
contained svg-files are dynamically created again (using the same temporary
svg file names). 

The first time I export a pdf from my application everything works just fine.
But the second time, the changed svg-pictures are not taken into account at all
for the pdf generation, the second pdf shows exactly the same svg images as the
first one, even though the files have been changed. 

It seems now that this image cache (which seems to be somewhere somehow) keeps
hold of the images, even though I use a completely new Driver object and thus
there should be no reason to keep hold of the old cached images. Isn't there 
any possibility to disable image caching? Or to empty the image cache??

Yes shure, as a work-around, I could give each new svg file a new temporary
name, and generate a according fo-file each time for the pdf generation, then 
it would probably work. But aside from the fact that this would mean more work 
for me, I think my application could run into a memory problem then, since the 
image cache would grow each time a new pdf with other pictures is generated.

What can I do? 

Thanks for helping me.

-- rolf


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: Problems with Driver image cache

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
On 31.01.2006 13:19:50 Rolf Bruderer wrote:
> Jeremias Maerki <dev <at> jeremias-maerki.ch> writes:
> > See http://xmlgraphics.apache.org/fop/0.20.5/graphics.html#caching on
> > how to reset the image cache in FOP 0.20.5 between rendering runs. Note
> > that this function is not available anymore in the latest version since
> > there the cache works differently. It has much better memory reclaiming
> > abilities (using weak references) so a cache reset method should not
> > be necessary if you use unique URLs. 
> 
> Hi
> 
> Thank you very much for the fast answer and your advice how to reset
> the cache. That was very helpfull.
> 
> Anyway I have to say, that I think that this static image cache is 
> not such a good solution (even not with weak references).

I'm sure you can come up with suggestions for a much better image cache.
We'd love to apply patches in that direction. Anyway, we plan to add an
environmental class that will hold configuration information that
doesn't change between rendering runs. When this is available I want to
attach the existing image cache to that environmental class. That will
make the image cache less "static".

> > so a cache reset method should not be necessary if you use unique URLs. 
> 
> Caching only with respect to the urls without considering if the url 
> content has changed inbetween (e.g. modification date) seems not very 
> proper to me.

As I said above, we're looking forward to any patches that improve the
current situation.

> If done so, the user should at least have a chance to decide whether to
> bypass this cache or to empty it. If I understood you right, in the latest
> version it is not even possible anymore to empty the cache?

No, not at the moment.

> > On the other side, if anyone submits a patch to retrofit this method
> > we will surely consider adding it. 
> 
> If you give me some hint how to access the cache and if I find some time
> I would try to do it. But for the moment I think that I simply stick 
> to the older version.

Look into org.apache.fop.images.ImageFactory. It should be very easy to
do.

> > However, I'd prefer an extension attribute on fo:external-graphic
> > that signals FOP to bypass the image cache entirely.
> 
> I don't think that changing the fo:external-graphic specification to the
> needs of FOP is something that is in your power or is it? 
> I don't agree that this attribute would be a good solution. Since a 
> writer of a FO-file usualy does not want to concern about cache bypassing.
> FOP should better use the correct (cached or reloaded) picture in any case.

I'm not suggesting altering the FO specs. I'm suggesting an proprietary extension
(!) attribute. Something like:

<fo:external-graphic src="http://localhost/MyImageServlet" fox:bypass-cache="true"/>
(where fox is xmlns:fox="http://xmlgraphics.apache.org/fop/extensions")

Usually, the stylesheet-writer knows that an image is not cacheable so
this is actually quite feasible. If you have a better approach that does
not cost a lot of performance because of network roundtrips then I'm all
for it. Another idea could be to add a user-configurable list of URL
patterns that will not be cached by FOP. Also very easy to do.

> Those are just my thoughts about it. In any case I am very thankful for your
> help and I appreciate your work. Thank you very much.

You're welcome. I'm looking forward to your suggestions and patches.


Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: Problems with Driver image cache

Posted by Rolf Bruderer <ro...@zuehlke.com>.
Jeremias Maerki <dev <at> jeremias-maerki.ch> writes:
> See http://xmlgraphics.apache.org/fop/0.20.5/graphics.html#caching on
> how to reset the image cache in FOP 0.20.5 between rendering runs. Note
> that this function is not available anymore in the latest version since
> there the cache works differently. It has much better memory reclaiming
> abilities (using weak references) so a cache reset method should not
> be necessary if you use unique URLs. 

Hi

Thank you very much for the fast answer and your advice how to reset
the cache. That was very helpfull.

Anyway I have to say, that I think that this static image cache is 
not such a good solution (even not with weak references).

> so a cache reset method should not be necessary if you use unique URLs. 

Caching only with respect to the urls without considering if the url 
content has changed inbetween (e.g. modification date) seems not very 
proper to me. 
If done so, the user should at least have a chance to decide whether to
bypass this cache or to empty it. If I understood you right, in the latest
version it is not even possible anymore to empty the cache?

> On the other side, if anyone submits a patch to retrofit this method
> we will surely consider adding it. 

If you give me some hint how to access the cache and if I find some time
I would try to do it. But for the moment I think that I simply stick 
to the older version.

> However, I'd prefer an extension attribute on fo:external-graphic
> that signals FOP to bypass the image cache entirely.

I don't think that changing the fo:external-graphic specification to the
needs of FOP is something that is in your power or is it? 
I don't agree that this attribute would be a good solution. Since a 
writer of a FO-file usualy does not want to concern about cache bypassing.
FOP should better use the correct (cached or reloaded) picture in any case.

Those are just my thoughts about it. In any case I am very thankful for your
help and I appreciate your work. Thank you very much.

Greetz,
rolf


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: Problems with Driver image cache

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
You're mixing things. The thread you referenced is about something else.
It's about RTF output and FOP 0.91beta/Trunk. Since you're talking about
a Driver object, you're still on FOP 0.20.5 where the image cache works
differently.

See http://xmlgraphics.apache.org/fop/0.20.5/graphics.html#caching on
how to reset the image cache in FOP 0.20.5 between rendering runs. Note
that this function is not available anymore in the latest version since
there the cache works differently. It has much better memory reclaiming
abilities (using weak references) so a cache reset method should not
be necessary if you use unique URLs. On the other side, if anyone
submits a patch to retrofit this method we will surely consider adding
it. However, I'd prefer an extension attribute on fo:external-graphic
that signals FOP to bypass the image cache entirely.

To answer you question about "where" the image cache is: It's held by a
static variable so it is tied to the class loader that loaded
the FopImageFactory class.

On 31.01.2006 08:28:04 Rolf Bruderer wrote:
> Hello
> 
> I have another problem which seems to occur because of the same image cache as 
> described in "Re:still have problems with with fo:external-graphics and rtf".
> 
> I try to generate pdf files dynamically, containing some svg-files (using
> fo:external-graphics). Each time my application creates a pdf it uses the 
> same FO-file for the transformation (since layout stays the same), but the
> contained svg-files are dynamically created again (using the same temporary
> svg file names). 
> 
> The first time I export a pdf from my application everything works just fine.
> But the second time, the changed svg-pictures are not taken into account at all
> for the pdf generation, the second pdf shows exactly the same svg images as the
> first one, even though the files have been changed. 
> 
> It seems now that this image cache (which seems to be somewhere somehow) keeps
> hold of the images, even though I use a completely new Driver object and thus
> there should be no reason to keep hold of the old cached images. Isn't there 
> any possibility to disable image caching? Or to empty the image cache??
> 
> Yes shure, as a work-around, I could give each new svg file a new temporary
> name, and generate a according fo-file each time for the pdf generation, then 
> it would probably work. But aside from the fact that this would mean more work 
> for me, I think my application could run into a memory problem then, since the 
> image cache would grow each time a new pdf with other pictures is generated.
> 
> What can I do? 
> 
> Thanks for helping me.
> 
> -- rolf


Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org