Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

UserAbortException adding browserfield to MainScreen

What exactly is a UserAbortException and why would it occur when adding

a browserfield to a mainscreen which is on the display stack but not currently

on the top? I think this is version specific to an 8330 with 4.3.0 but can't

tell. I'm also getting a problem rendering if I don't add to a screen right

away as some html renders as if the field width is zero.




Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: UserAbortException adding browserfield to MainScreen

On the same device, at a later point ( I'm trying to patch this, and code and thinking are getting a bit confused, could be really stupid), I have another bizarre problem. How is it possible for this to happen?

The try block throws a NullPointerException but AFAIK neither mainscreen or field are null ( deleteall executes

and then mainscreen.add(field) throws an already parented error as below:


java.lang.IllegalStateException: Field added to a manager while it is already parented.
the new mainscreen is my class,  com.phluant.icon.PhluScreen@cbcd4f26
and the field is this, specific content doesn't seem to matter.


// how is it possible to get an "already parented error" after this?

Manager mm=field.getManager();
           if (mm!=null) mm.deleteAll();


// this seems to throw an NPE right after above two statement execute
          try { _mainScreen.add(field);   } catch (Exception e)
   { e1=e.toString()+"at"+dbx+":";
    _mainScreen = new PhluScreen(Phlauncher.m_us);



BlackBerry Development Advisor
Posts: 15,766
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: UserAbortException adding browserfield to MainScreen

This indicates that the field has already been added to a manager.  Do you have nested managers on your screen?  If so, you may not be removing fields from all managers with the deleteAll call to the single top level manager.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: UserAbortException adding browserfield to MainScreen

Thanks but I think the first question is the important one regardint a userabortexception. Probably the

already parented problem occured because the screen.add(field) failed after already adding the field but

before returning. I guess the question may then be something like given that I have not overridden

add(field) in my screen class, what could cause the add() to throw a null pointer exception with

a browser field after apparently having done the association but prior to returning? This only seems

to happen on a 4.3.0 8330 from which I can not get details. I guess I could try it on simulator

but thought there may be a known easy answer.


Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: UserAbortException adding browserfield to MainScreen

I finally ran the simulator on this with my 256Meg machine. First, if you have to write Pentium code that

wastes memory, try to make it COHERENT so you stand a better than 50% chance of accessing something

in PHYSICAL memory. My task manager hasn't gone over1% since opening this up and worse I NEED the

IDE to get the debug output and stack traces but I really want these as TEXT, not cute little windoze.

Anyway, assuming I type this right, the problem seems to occur, Oh * now the IDE won't repaint,


anyway, as near as I can rememebr from 1/2 hour ago when I STARTED to close the emulator,

the stack trace ended up in an Asserts.something from two text rendering mthods after calling finishLoading

on browser content.


Oh, wauit, it repainted, but I just wanted the text that I now have to retrype,


Asserts.productionUserAbortAssert()) 42


HTMLRendererWithTextFloaw ( wtf- it just took away the stack trace and I am too tired to rememebr

what I was trying to retype....)





Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: UserAbortException adding browserfield to MainScreen

How much memory are you supposed to have to get MDS, fledge, and the IDE to all be in memory

at the same time? #$%^? I just spent all day with the task manager never going over a few pct of

CPU because it seemed every !@#$@#%ing memory access ended up going to disk. Sometimes code

gets big and java seems to think it is too smart to let programmers do memory management but

itsn't there some way to increase memory and cache coherence? I can't imagine how much memory you

need to make this work. I guess there could also be lock starvation issues- if someone decided to synchronize

everything for safety that could slow things down a lot too. aaaarrrgggh- there is probably someone somewhere

designing flash ads with 2GB and 2+Ghz machine wondering why people complain when

they end up having to watch his ad....


Seriously, how much memory do you need? I think task mananger told me I had about 500M used

but I thought others here with machines probably that well equipped were still complaining....


I don't think I ever got the GUI in the IDE to scroll more than a few times before a 1-2 minute wait and

the same with stepping. I don't recall I've ever seen a Swing GUI that wasn't noticably slow, maybe they

never fixed that since the last time I got stuck with one...




It looks like I can get some idea of how the code I'm using is structured so this may eventually work but I'm

not sure if anyone will still be young enough to care by the time the GUI lets me scroll to the variables I need



Has anyone ever tried to profile this?



Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: UserAbortException adding browserfield to MainScreen

OK, it turns out they can all run reasonably ( still slow but usable ) on a single 256M machine- I now

have an acceptable ritual that even allows me to open another app or two Smiley Happy Task manager rarely

gets over a few pct but sometimes does max out while emulating my code. It I start MDS once,

then IDE followed by emulator and restart then occaisionally, seems fine.


Anyway, the problem turns out to be due to an assert that is possibly equivalent to HTMLBrowserField._destroyed

being true. I could set a BP on this field and in fact observe the problem is due to undisplay, in this case


HTMLBrowserField.destroy(  ) 120
HTMLBrowserField.onUndisplay(  ) 80
Field.callOnDisplayOrUndisplay( boolean ) 1039
Manager.callOnDisplayOrUndisplay( boolean ) 535
Manager.callOnDisplayOrUndisplay( boolean ) 540
Manager.callOnDisplayOrUndisplay( boolean ) 540
Screen.callOnUiEngineAttached( boolean ) 438
UiEngineImpl.popScreen( Screen ) 1146
UiApplication.popScreen( Screen ) 258



the actual assert fails at

[ manually typed in places, may have errors, should be the jde ]

Asserts.productionUserAbortAssert( boolean ) 42
HTMLRendererWithTextFlow.parseData( ) 1198
HTMLRendererWithTextFlow.finishProcessingData( ) 928
BrowserContentImpl.finishLoading( ) 594
HTMLBrowserContent.finishLoading( ) 510


It turns out that this creates a problem if I want to save the field but not the screen. I guess I could preserve

field and screen but the simple act of popping screen off of display stack seems to trigger this. The stack dump

seems to contain undocumented methods so I'm not entirely sure what would be safe to override.


In any case, I have a version specific kluge that seems to work but it may help if I had a more

precise diagnosis.