Random crashes in GenericStyleArea.visibleParToAllParIndex
See original GitHub issueExpected Behavior
Shouldn’t throw exception but return the index of the paragraph.
Actual Behavior
Sometimes when I call this method it reaches: throw new AssertionError("Unreachable code");
As much as I can tell the problem is that the element in the visibleParagraphs is the same as the one in the paragraphs but they are not the same reference therefore the search can’t find it. I have no idea how is this possible.
Reproducible Demo
Unfortunately I only have this rarely…
Environment info:
- RichTextFX Version: 0.9.1
- Operating System: Ubuntu 18.04 but happened in 16.04 too.
- Java version: “1.8.0_181”
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Random crashes since April. - Microsoft Community
Getting random crashes at random times (sometimes minutes after windows loads) since around April on a windows 10 pc (installed on internal ...
Read more >Modern Warfare 2 - How To Fix Random Crashes on PC
For more information, follow this guide:https://www.techy.how/tutorials/modern-warfare-2-fix- random - crash -pcA short tutorial on how to ...
Read more >Fix Valorant Crashing | Launch, Random Crashes & Instability
Trying to play Valorant, but it keeps randomly crashing or crashing on launch? This video covers a few common issues that could be...
Read more >Random crashes during gameplay - Support - Larian Studios
Try exiting out of the Steam client, if applicable, and starting the game directly from the '..\SteamApps\common\Baldurs Gate 3\bin' folder, by right clicking ......
Read more >KNOWN ISSUE: Crashing at Random, Due to GPU-Related ...
Game crashing! Crash to desktop joining new and existing missions. Long load time or crash. Game keep crashing at random moment. Game Crashes...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Jugen Thank you for your great job at first. I write some test cases for this problem and make a pull request.
@Jugen I have a fix for this issue in PR #795, which also fixes #788
Earlier today I had a look at #788 and later at this issue and noticed that both issues are related somehow to
MaterializedListModification.trim()
. It is in the stack of #788 and in Jugen’s comment in this issue. So used the tests from @lhttjdr in PR #790 to see what’s going on intrim()
and why it may failvisibleParToAllParIndex
.The problem was that
MaterializedListModification.trim()
, which is invoked here, usesequals()
to compare paragraphs and classParagraph
overridesequals()
and returnstrue
if paragraph text and styling is equal.But this is not wanted because it keeps old outdated paragraphs and drops newly added paragraphs if the paragraph text and styling is equal.
The solution is to use a
trim
method that uses reference comparison instead of object comparison. Unfortunately there is no such method in ReactFX, so I copied the related methods to RichTextFX and modified them.Below is some detailed information how I used println’s to see whats going on:
I’ve added println’s to the main constructor of class
Paragraph
:To
GenericStyledArea.visibleParToAllParIndex()
:and to
GenericEditableStyledDocumentBase$ParagraphList.observeInputs()
:Here is
p(mod)
:When you run test get_first_visible_paragraph_index_with_all_blank_lines, which fails without the fix, you get following output:
You see that there are created four paragraphs. The first in the constructor of
GenericEditableStyledDocumentBase
. The other three are the three empty lines that the test adds to the text area.Below is the modification before
trim
. 1596606895, which was created in the constructor, should be removed. Three new paragraphs should be added.Below is the modification after “buggy”
trim
. So the first paragraphs from the “added” and from the “removed” lists was removed. IOW the paragraph 1596606895 stays in the list of paragraphs and is not replaced by 713924259, which causes the bugs in #777 and #788.And here is the output of
visibleParToAllParIndex()
. You see the visible paragraph is still at 1596606895, but 1596606895 is no longer in the list of paragraphs.And here is the output with fixed
trim
. The initial paragraph 1950984118 is removed and the visible paragraph is correctly at 1714800072.In the above case, the new
trim
does nothing and you might have the impression that we could remove it at all. This is not true. E.g. runJavaKeywordsDemo
, and enter some text. You’ll notice modifications that change from e.g. 20 paragraphs to 0 paragraphs, which is caused bycodeArea.setStyleSpans(...)
: