Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Loading Performance #11

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open

Conversation

bekoeppel
Copy link
Owner

For big mindmaps, parsing the whole XML takes a while. I have replaced it by a stream parser, and progressively load the mindmap. As a result, Droidplane immediately after open starts showing nodes (the first ones in the XML file), and keeps on adding more nodes as the XML is parsed.

Benedikt Koeppel added 30 commits November 27, 2023 11:32
Issue caused by calling getChildNodes on the root MindmapNode, and then
immediately again from the UI thread, thus resulting in two separate
list of child nodes on the root node.

caching needs to be synchronized
…, neither work on Android"""

This reverts commit 39b4cd7.
loads document as we go, expanding the mindmap
not loading icons, links, etc. yet
Benedikt Koeppel added 6 commits January 3, 2024 15:01
app/src/main/java/ch/benediktkoeppel/code/droidplane/MainActivity.java
app/src/main/java/ch/benediktkoeppel/code/droidplane/MindmapNode.java
app/src/main/java/ch/benediktkoeppel/code/droidplane/view/HorizontalMindmapView.java
app/src/main/java/ch/benediktkoeppel/code/droidplane/view/MindmapNodeLayout.java
app/src/main/java/ch/benediktkoeppel/code/droidplane/view/NodeColumn.java
@bekoeppel
Copy link
Owner Author

@Tibi: if you're curious, here's what I've been working on on Droidplane recently. Do you want to give this a test and see if you find any issues?

I have two 40-60 MB mindmap files (with 230k resp 370k nodes). Loading that in Droidplane always took >30 seconds. With the streaming XML approach, I immediately open the files, get to browse the first branches of the mindmap (where I have most recent / most used information), while the rest of the mindmap keeps loading in the background).

I've been using this branch for a few months now and been pretty happy with it. I would appreciate if you give it a spin and see if you find new issues.

Known issue: I've merged your search feature into here, and at the moment search breaks while the mindmap is still loading. I'll try to fix that later.

@Tibi
Copy link

Tibi commented Jul 1, 2024

Hi Benedikt,

I can test the branch for regressions, but I don't have such huge maps.
Maybe you could publish it as beta to the playstore so both versions are available for others to test?

Cheers!

@Tibi
Copy link

Tibi commented Jul 3, 2024

Hallo Benedikt,

I could test a bit and found nothing but as I said my maps are not huge. I also couldn't find some big maps online to test with.

@Tibi
Copy link

Tibi commented Jul 3, 2024

Ah no, I was testing with the wrong version! When I try to open my main map with this branch I get this:

FATAL EXCEPTION: AsyncTask #1
Process: ch.benediktkoeppel.code.droidplane.dev, PID: 4569
java.lang.RuntimeException: An error occurred while executing doInBackground()
    at android.os.AsyncTask$4.done(AsyncTask.java:415)
    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:381)
    at java.util.concurrent.FutureTask.setException(FutureTask.java:250)
    at java.util.concurrent.FutureTask.run(FutureTask.java:269)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
    at java.lang.Thread.run(Thread.java:1012)
Caused by: java.lang.RuntimeException: org.xmlpull.v1.XmlPullParserException: unresolved:   (position:TEXT @3078:13 in java.io.InputStreamReader@956381d) 
    at ch.benediktkoeppel.code.droidplane.controller.AsyncMindmapLoaderTask.loadDocument(AsyncMindmapLoaderTask.java:297)
    at ch.benediktkoeppel.code.droidplane.controller.AsyncMindmapLoaderTask.doInBackground(AsyncMindmapLoaderTask.java:107)
    at ch.benediktkoeppel.code.droidplane.controller.AsyncMindmapLoaderTask.doInBackground(AsyncMindmapLoaderTask.java:34)
    at android.os.AsyncTask$3.call(AsyncTask.java:394)
    at java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644) 
    at java.lang.Thread.run(Thread.java:1012) 
Caused by: org.xmlpull.v1.XmlPullParserException: unresolved:   (position:TEXT @3078:13 in java.io.InputStreamReader@956381d) 
    at com.android.org.kxml2.io.KXmlParser.checkRelaxed(KXmlParser.java:305)
    at com.android.org.kxml2.io.KXmlParser.readEntity(KXmlParser.java:1285)
    at com.android.org.kxml2.io.KXmlParser.readValue(KXmlParser.java:1402)
    at com.android.org.kxml2.io.KXmlParser.next(KXmlParser.java:393)
    at com.android.org.kxml2.io.KXmlParser.next(KXmlParser.java:313)
    at ch.benediktkoeppel.code.droidplane.controller.AsyncMindmapLoaderTask.loadRichContentNodes(AsyncMindmapLoaderTask.java:447)
    at ch.benediktkoeppel.code.droidplane.controller.AsyncMindmapLoaderTask.loadDocument(AsyncMindmapLoaderTask.java:194)
    at ch.benediktkoeppel.code.droidplane.controller.AsyncMindmapLoaderTask.doInBackground(AsyncMindmapLoaderTask.java:107) 
    at ch.benediktkoeppel.code.droidplane.controller.AsyncMindmapLoaderTask.doInBackground(AsyncMindmapLoaderTask.java:34) 
    at android.os.AsyncTask$3.call(AsyncTask.java:394) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:264) 
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644) 
    at java.lang.Thread.run(Thread.java:1012) 

@bekoeppel
Copy link
Owner Author

Thanks for reporting this - not good indeed. Do you have an example file you can share with me that triggers the behavior?

@Tibi
Copy link

Tibi commented Jul 3, 2024

I guess it must be a file created with an older version of FreePlane because creating a new one and just putting a non-breaking space in a node's note works, it gets written as   instead of  
mms.zip

@bekoeppel
Copy link
Owner Author

Thanks for the test files, interesting... My understanding is that   is not really valid XML (StackOverflow). I'll try if I can tweak the XmlPullParser to accept it, either by adding a DTD or using defineEntityReplacementText, but I'm not sure if Android's implementation of the XmlPullParser actually supports that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants