Skip to main content
November 10, 2009
Question

Suggestions for increased performance and better memory utilization for FTE

  • November 10, 2009
  • 2 replies
  • 4667 views

We all know that there is a pretty big downside to creating potentially thousands of DisplayObjectContainers (TextLines).

o - they are slow to create

o - they may be short lived

o - they occupy lots of memory

o - they may need to be generated frequently

Currently, there is only one way to find out all the information you need and that is to create all the TextLines for a given data set.

This means that FTE does not scale well. It becomes very slow for large data sets that need to be regenerated.

I am proposing a possible solution and hope that Adobe will consider it.

If we had the right tools we could create a sliding window of display objects. With large data sets only a fraction of the content is actually visible. So only the objects that are actually visible need to be created. There is no way to do this efficiently with FTE at the present time.

So we need a few new methods and classes that parallel what you already have.

New Method 1)

TextBlock.getTextLineInfo (width:Number, lineOffset:Number, fitSomething:Boolean)  : TextLineInfo

This method returns simple information about all the lines in a text block. No display objects are generated.

class TextLineInfo

{

    public var maxWidth:Number;   // maximum width of all the textlines in the textBlock
    public var totalHeight:Number;  // totalHeight of all the textlines in the textBlock

    public var numLines:int;           // number of lines in the lineInfo Array
    public var lineInfo:Array;           // array of LineInfo items for each textline

}

class LineInfo // sample - more or less may be needed
{
    public var rawTextLength:int;
    public var textWidth:Number;
    public var textHeight:Number;

    public var ascent;

    public var descent;
    public var textBlockBeginIndex:int;
}

Now getTextLineInfo needs to be as fast as possible. Find an advanced game programmer to optimize, write it in assembler, put grease on it.... do whatever it takes to make it fast.

New Method 2)

TextBlock.createTextLines (textLineInfo:TextLineInfo, begIdx:int, endIdx:int) : Array

Creates and returns an Array of TextLine objects based on the previously created TextLineInfo. A range can be specified.

It should be obvious that the above functions will improve the situation. Since this parallels what you already have it should not be earth shaking to implement.

New Display Object type

Much of the time you do not need a full blown Display Object Container for a TextLine. I suggest an additional lightweight TextLine class. A good parallel would be similiar to the difference between Sprite and Shape.

Now I have some done some testing with this idea. Since you cannot implement this fully as it stands, I had to make some concessions. This sample contains 100,004 characters of data. You can resize it and it will always be fast. This sample only creates the visible portion of the display, but you may scroll into view the invisible portions. Each time the page is resized, it will jump back to the top, because of the limitations of FTE currently.

The sample also contains a caret and allows the selection of an area but no editng, copy, paste  etc., is available for this test.

If I did not do special handling for this, it would lock up for sure and be very user unfreindly.

Now it takes a moment to load 100k into the TextElement.so there may be a pause before you see that data. I may need to improve this. Once loaded it performs quite well.

Without the above or similiar optimizations. FTE is just not going to scale up very well at all.

Don

This topic has been closed for replies.

2 replies

Known Participant
November 10, 2009

Hi Don,

I am facing the same dillema and was glad to hear that Flash 10.1 will bring some improvements, e.g. the re-use of the TextLine instances could prove to be a big one.

As things stand, I am with you on the desire for an additional light weight class the will not create a TextLine but a TextLineInfo object in lines with what you describe. Maybe TextBlock should (optionally) cache the TextLineInfo data to reuse when createTextLine is called later?

Did you log a feature request? ... if so let us know so we can vote for it

Regards, Benny

November 10, 2009

Hi Benny,

Seems like reuse of TextLine instances is more about memory saving and not about performance.

We will also have the ability to cache the TextLineInfo in action script...

I did log an additional entry into an already existing bug report which is an old entry: "New text engine is a memory hog"

https://bugs.adobe.com/jira/browse/FP-1164

Should this be posted elsewhere ? How should this be directed ?

Don

Adobe Employee
November 10, 2009

Actually, the new recreateTextLine method is all about performance.  Creating a DisplayObject takes significant time.  Reuse also takes some load off the GC, but that's secondary.  We are thinking about things like your TextLineInfo suggestion for the next release.

Jeff Mott

Flash Player

November 10, 2009

Yeah, lol the sample...

http://sms.pangolin.com/data100k/

Don