Why Javafx UI hangs or become unresponsive on using Plarform.runLater() ?
Jonathan Giles
jonathan.giles at oracle.com
Sun Oct 19 20:08:47 UTC 2014
The point Tom and Michael make is correct - TextArea is not virtualised,
which means that there is indeed a Text node internally containing all
text you've set on the TextArea - even if it is not visible. This is
clearly not efficient for large amounts of text - as Michael said you
want to virtualise the visuals so that you don't have all the text in a
Text node at once.
One way that people do this is with the ListView control (or its
underlying implementation). There exists a few options you should
explore, including Tom's implementation and RichTextFX [1] by Tomas Mikula.
[1] https://github.com/TomasMikula/RichTextFX
-- Jonathan
On 20/10/2014 9:01 a.m., Navdeep Singh Sidhu wrote:
> Sorry Tom, didn't get you :) :P . TextArea is inefficient for code editing
> or for printing output??
>
> On Sun, Oct 19, 2014 at 11:48 PM, Tom Schindl <tom.schindl at bestsolution.at>
> wrote:
>
>> TextArea in JavaFx is very ineffecient because it is not virtual!
>> Codeeditors like the styledtext one i wrote use virtualflow/Listview to
>> perform with many lines.
>>
>> Tom
>>
>> Von meinem iPhone gesendet
>>
>>> Am 19.10.2014 um 20:11 schrieb Navdeep Singh Sidhu <
>> navdeepsingh.sidhu95 at gmail.com>:
>>> Thanks sir, that is really a great suggestion. So i have to add a
>> listener
>>> to scroll bar. Am i right ??
>>>
>>> And there is not such thing like silly question :) . Not having knowledge
>>> is not bad, but having no curiosity to pursue knowledge is bad. I'm
>> working
>>> on parallel computing framework and my target is to multiply matrices
>> with
>>> BigInt elements and dimensions, for any number of given matrices (that
>> also
>>> can be in BigInt). On Netbeans my sample problem gives me the output
>>> without crashing it or making it unresponsive. So i'm trying to achieve
>>> similar in JavaFX. The main target of my project is to implement problems
>>> in parallel computing and i'm using JFX as front-end because it is good
>>> looking and easy to implement than Swing. But this is my first project in
>>> JFX and i am facing many problems while implementing, main problem is UI
>>> lag bcz in back-end different threads collect data and those threads do
>> the
>>> computations concurrently and send result data to UI.
>>>
>>> And also is there anyway i can apply monokai like theme (or any other
>>> coding style theme) to my TextArea which i'm using in Code editor for
>> JAVA
>>> with suggestion popups like Netbeans or eclipse?
>>>
>>>> On Sun, Oct 19, 2014 at 9:59 PM, Michael Berry <mjrb5 at kent.ac.uk>
>> wrote:
>>>> Perhaps a silly question - but do you really need millions of lines in
>> the
>>>> text area? When you're displaying this much text then from my
>> understanding
>>>> things are bound to hang (simply because of the processing overload) and
>>>> there's not really a great deal you can do about it. You can see if
>> there's
>>>> any extraneous delay by profiling and seeing if there's any GC
>> bottlenecks
>>>> (or suchlike) then tweak those options, but I doubt you'll ever get to
>> no
>>>> delay at all with dumping this much data in a textarea.
>>>>
>>>> I'm not aware of the details of your application, but can you just
>> create
>>>> the text in memory somewhere else, and create an FX component that acts
>>>> like a text area, but dynamically reads the text in from memory as the
>> user
>>>> scrolls? This way you'll just be altering a relatively small amount of
>> text
>>>> much more continuously, and shouldn't notice much of a delay. (I took a
>>>> similar approach with Swing a long while ago for a project, but sadly
>> can't
>>>> find the source for that now.)
>>>>
>>>> Michael
>>>>
>>>> On 19 October 2014 16:58, Navdeep Singh Sidhu <
>>>> navdeepsingh.sidhu95 at gmail.com> wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> I know this mailing list is for OpenJFX developers and to discuss
>>>>> development related issues. I don't know it is OK to post my query
>> here or
>>>>> not. But i assume if you people are developing the OpenJFX, so there
>> will
>>>>> be no other person better than you or have more knowledge related
>> OpenJFX
>>>>> than you guys :) .
>>>>>
>>>>> My query is that i'm trying to develop an IDE for parallel computing
>>>>> integrated with framework and output from all nodes has to be
>> represented
>>>>> in TextArea. I am using multiple threads to collect Output from all the
>>>>> nodes and appending that output on TextArea using Platform.runLater(),
>> i
>>>>> am
>>>>> even using flags to reduce the flood on UI thread, that output will be
>>>>> appended if the output is larger than 50000 lines then after each 50000
>>>>> lines to TextArea else it will be appended as it is. Even submitting
>> one
>>>>> task in the system, UI hangs when trying to print millions of line
>> output
>>>>> on TextArea and i couldn't test it with multiple tasks. Can you
>> suggest me
>>>>> something to prevent UI thread from becoming unresponsive. I know i'm
>> not
>>>>> good programmer as you guys but i'm trying to learn JFX and new to
>> this.
>>>>> BTW thank you guys for such a beautiful interface in JAVA. :)
>>>>>
>>>>> Regards
>>>>> Navdeep Singh Sidhu
>>>>
More information about the openjfx-dev
mailing list