Skip to main content
February 20, 2009
Question

Null Exception During updateContainer()

  • February 20, 2009
  • 9 replies
  • 2577 views
I've been seeing an intermittent exception getting thrown sometimes during the updateContainer() call in the flow composer. It only seems to occur when an updateAllContainers() call is triggered during flushPendingOperations() in EditManager's enter frame handler method. It also seems to be more reproducible with longer text flows (length > 20000), when you are editing closer to the top of the text flow, and when you type faster. I can usually reproduce this within a few minutes if I paste in a lot of text and then click around in different places near the top of the flow and start typing quickly. Also, it seems to have something to do with a new line being created somewhere in the middle of the flow and maybe the new line is not initialized or created when the enter frame handler happens to trigger a call to update the containers. I haven't been able to pinpoint the exact scenario, but I have never seen this error occur outside of the context of EditManager's enterFrameHandler method.

Here are a few stacktraces for the errors that occur in sequence when this situation occurs:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at flashx.textLayout.compose::StandardFlowComposer/releaseLines()
at flashx.textLayout.compose::StandardFlowComposer/updateContainer()
at flashx.textLayout.compose::StandardFlowComposer/updateAllContainers()
at flashx.textLayout.edit::EditManager/updateAllContainers()
at flashx.textLayout.edit::EditManager/finalizeDo()
at flashx.textLayout.edit::EditManager/doOperation()
at flashx.textLayout.edit::EditManager/flushPendingOperations()
at flashx.textLayout.edit::SelectionManager/enterFrameHandler()
ArgumentError: Error #2004: One of the parameters is invalid.
at Error$/throwError()
at flash.text.engine::TextBlock/createTextLine()
at flashx.textLayout.elements::TextFlowLine/ http://ns.adobe.com/textLayout/internal/2008::recreateTextLine()
at flashx.textLayout.elements::TextFlowLine/getTextLine()
at flashx.textLayout.compose::StandardFlowComposer/releaseLines()
at flashx.textLayout.compose::StandardFlowComposer/updateContainer()
at flashx.textLayout.compose::StandardFlowComposer/updateAllContainers()
at flashx.textLayout.edit::EditManager/updateAllContainers()
at flashx.textLayout.edit::EditManager/finalizeDo()
at flashx.textLayout.edit::EditManager/doOperation()
at flashx.textLayout.edit::EditManager/flushPendingOperations()
at flashx.textLayout.edit::SelectionManager/enterFrameHandler()

Thanks,
Brent
This topic has been closed for replies.

9 replies

March 20, 2009
Robin,

Thanks for look this.

I tested in flex SDK build 4.0.0.5409 and the bug is fixed and work fine!

Expecting to feature of manipulation of images (resize it and move it) =D

Thanks for atention.

-Marcos
Adobe Employee
March 19, 2009
fyi, I submitted a possible fix for the RTE from findFirstAndLastVisibleLines. I say possible because I was unable to actually repro the crash. It will have to percolate out to Gumbo, but should be in Build 396. You can find the latest downloads as part of the Gumbo open source drops -- see http://opensource.adobe.com/wiki/display/flexsdk/Gumbo.
March 19, 2009
Where do I find the link of latest build to download (Flex 3)?
Adobe Employee
March 19, 2009
FWIW I reproed the earlier problem in your first post. Fix in process.

Thanks,
Richard
March 19, 2009
Richard, Great to hear about the releaseLines() fix! BTW, I don't know if anyone has looked at findFirstAndLastVisibleLine() in ContainerControllerBase, but I think there's a very similar case in that method to the null exception issue in releaseLines(). Something related to getTextLine() on TextFlowLine returning null.

Brian, I'm just using random lorem ipsum strings generated from http://lipsum.com/. After I posted about that, I started having trouble reproducing the issue with the exact same code as I had previously. I keep coming back to thinking that it has something to do with when flushPendingOperations() gets called during the enterFrameHandler() in the edit manager. Seems like sometimes the text flow may happen to be in some in-between state which prevents certain operations from executing successfully. Will try to narrow down some more to provide some better instructions for consistent reproduction.

I can't say for sure that the errors I'm seeing are the same as those reported in the Jira issue you mentioned. Seems like they could at least be related. Now that I look at it again, it looks like the Jira issue is related to the null TextLine issue similar to the releaseLines() thing that Richard mentioned a fix for. I'm not using linked containers in my case, but I am working with longer text flows with content height larger than compose height. I do seem to get errors thrown more often as the flow grows in size. Am still trying to pinpoint the exact scenarios that cause errors.

Thanks,
Brent
March 15, 2009
Brent,

Thanks for looking this. Your help is very useful.

The source code of framework is closed, right? Otherwise, where can I download it?

Regards,
Marcos
March 16, 2009
Yes, no source. At this point the closest thing you'll get to accurate documentation is in the Gumbo LiveDocs located at http://livedocs.adobe.com/flex/gumbo/langref/. And actually, it looks like they've updated the docs, so they should be fairly accurate as of today. Once you spend some time studying the documentation and experimenting with TLF, it becomes easier to understand how to work with the classes.
March 18, 2009
Here's another stack trace that I'm seeing all of the sudden. Seems like it could be related to the first stack traces in the thread. It's something that's going on again during the enterFrameHandler/flushPendingOperations again. I seem to be able to replicate this one fairly consistently in my app, but I have not tried yet in a cleaner setup. I have a button that calls editManager.splitParagraph() twice in a row and then calls editManager.insertText() and passes a random chunk of text. If I click this button repeatedly, I usually get this exception within 10-20 clicks.

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at flashx.textLayout.edit::ParaEdit$/insertText()
at flashx.textLayout.operations::InsertTextOperation/doOperation()
at flashx.textLayout.edit::EditManager/doInternal()
at flashx.textLayout.edit::EditManager/doOperation()
at flashx.textLayout.edit::EditManager/flushPendingOperations()
at flashx.textLayout.edit::SelectionManager/enterFrameHandler()
March 15, 2009
Solutions?
March 15, 2009
I think I've narrowed this down a little more. It seems that sometimes a condition can occur in which the TextFlowLine's textLineExists property will return true and/or isDamaged() will return false, yet the getTextLine() method will return null immediately afterwards. I think that although the stack traces above are different, they're still connected. I'm not positive about this, but I think it's getting closer to the source of the issues. It seems like this situation tends to occur more at times when the text flow is at an in-between state. I still can't provide steps that will reproduce this issue 100% of the time.

As far as a workaround, you'll have to override a method upstream from the TLF methods that are causing issues. In my case, I'm already using custom composer, container controller, and edit manager classes. For your error happening in findFirstAndLastVisibleLine method of ContainerControllerBase (assuming that you're using DisplayObjectContainerController), you'll probably want to extend DisplayObjectContainerController and create a custom container controller class to use for your project that will allow you to override faulting behavior. I think that the container controllers are some of the easiest parts of TLF to extend.

In your case the closest method that you can override is scrollToPosition(activePosition:int, anchorPosition:int):void. The outdated documentation states that scrollToPosition() scrolls so that the text position is visible in the container. So, the first thing I would try is just to wrap the super.scrollToPosition call with a try/catch. I'm guessing that scrollToPosition() is not really a critical method call, if it fails now and then you can probably just ignore it. The other alternative is to try to figure out what the method is supposed to do and rewrite the complete logic for the method. This can take a lot of work, especially without adequate documentation for the classes you're overriding. Also, keep in mind that doing something like this is a WORKAROUND and NOT A SOLUTION. Although overriding and catching the error could get you by for now, hopefully eventually the TLF team will be able to track down the actual problem and then we can remove these overrides. The other pitfall of doing stuff like this with TLF right now is that TLF is still changing every day, and when you update to new builds it's likely that stuff will break on occasion and require a little patching.

Here's what you might try for the scrollToPosition method in your extended container controller:
override public function scrollToPosition(activePosition:int, anchorPosition:int):void
{
try
{
super.scrollToPosition(activePosition, anchorPosition);
}
catch (e:*)
{
trace("Caught error in scrollToPosition");
}
}

Sorry I don't have a better or *real* solution right now, but I hope this helps you to continue working until further progress is made on this issue.

-Brent
March 7, 2009
Hi Brian,

Thanks for looking into it.

The problem is very serious, several features are not working (I found three today).

The problem normally occurs when the scroll policy is off(ScrollPolicy.NO).

A great example of problem is the Spell Check, available to download in flash examples. The erro occurs in execution (when have more than two lines).

You can see also other example here (with code to download):
http://bugs.adobe.com/jira/browse/SDK-19229

If you find a temporary solution, please, let me know.

Regards,
Marcos Passos
March 5, 2009
I have the same problem.

Reproduce:
1. Create a first container.
2. Add a text with height more than the container.
3. Add a new controller.
4. Update all controllers.
5. Try also move the cursor, arrow top and arrow bottom.

Error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at flashx.textLayout.container::ContainerControllerBase/findFirstAndLastVisibleLine()
at flashx.textLayout.container::ContainerControllerBase/scrollToPosition()
at flashx.textLayout.edit::EditManager/finalizeDo()
at flashx.textLayout.edit::EditManager/doOperation()
at flashx.textLayout.edit::EditManager/splitParagraph()
at flashx.textLayout.edit::EditManager/keyDownHandler()
at flashx.textLayout.container::ContainerControllerBase/processKeyDownEvent()
at flashx.textLayout.container::ContainerControllerBase/keyDownHandler()

OBS: This problem is occurred immediately after update to Build 370, the previous version works fine.

My project is stopped because this.

Someone has a solution?

Thanks in advance.
brian_thomas2
Adobe Employee
Adobe Employee
March 6, 2009
Thank you marquinho.a for providing the steps, although from looking at the stack traces I think that you are each seeing different problems.

I am trying to build simple examples that will reproduce each of these. Any code samples you have would be very helpful as I try to get the bugs figured out! Thank you!
brian_thomas2
Adobe Employee
Adobe Employee
February 26, 2009
I am having difficulty reproducing this. Are you able to produce this in any of our sample applications? What build are you using? The labs release or a version of the SWCs from Flex Gumbo?
March 2, 2009
I was seeing this immediately after Build 370. Probably somewhere between 370-373. Using SWC's from Gumbo SDK Repo. I was already using an extended version of EditManager and was able to work around the issue with a try/catch somewhere in there. I will pull that out and update to latest SWC's from Gumbo SDK to make sure I can still reproduce and try to provide more specific instructions to do so if I'm still seeing the issue.

Thanks for looking into it.