flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Taylor Bastien <taylor.bast...@4point.com>
Subject Bitmap Caching and Multiple Partial Updates
Date Tue, 27 Aug 2013 20:41:43 GMT
Hi everyone.

I've been working on a very demanding Flex application running in AIR on the desktop and have
run into an issue I've never seen before.

The application (which displays live financial data being "long polled" from BlazeDS) has
to render thousands of components on screen at the same time with no benefit from clipping
and virtualization (i.e. clipping, scrolling or equivalent) and memory usage is very high.
Since there is some duplication across the contents of my components, especially on start-up
and as data changes over time, I've implemented bitmap caching. This has dropped memory usage
significantly (at some cost to rendering performance under load). Unfortunately, I've run
into a big problem which hopefully someone can help me figure out.

To make the caching work, I listen for an updateComplete event when a component is created
or invalidated. When it fires, I grab the contents of the component through a BitmapData.draw()
call. This works fine, however (the "however" is what kills you), sometimes the bitmap I grab
on updateComplete is empty or some of the sub-components (e.g. Label, Rect) are missing. This
happens most when the application is under heavy rendering load (e.g. on start-up when hundreds
or even thousands of components are being drawn at once), though I can't say there's a causal
relationship there.

This strange behavior has led me to think that it's possible for a single invalidation to
cause multiple updateComplete events to fire while the visual state of the component is still
in flux. For now, I've had to put in a timer to allow multiple updateCompletes (and multiple
snapshots to update the cached image) to be handled for a certain amount of time. This is
not really a solution because it is a big drag on performance and involves some fuzzy logic.

Some questions:

-          Is it even possible for:

1)      Flex to make partial draws of a component during a single invalidation cycle?

2)      An updateComplete to be dispatched before the component has been fully drawn?

-          If not, then my code must somehow be triggering the partial draws. Any tips on
stopping this from happening?

-          If I can't rely on updateComplete, is there a guaranteed way to know that a component
has been fully drawn to screen (or that it's at least in a state from which I can grab a valid
BitmapData)?

Feel free to send along questions if I've been unclear with anything. I appreciate any help
I can get, up to and including source for a "CacheableComponent/CacheableGroup" or equivalent
that behaves as it should.

Thanks,

Taylor | @RIAGrande on Twitter

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message