Bug 155812 - Open file with many page numbers spend too much time
Summary: Open file with many page numbers spend too much time
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Android Viewer (show other bugs)
Version:
(earliest affected)
7.5.4.2 release
Hardware: All Android
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: perf
: 155811 157720 (view as bug list)
Depends on:
Blocks: Performance
  Show dependency treegraph
 
Reported: 2023-06-13 09:04 UTC by Xiaoc
Modified: 2023-11-24 23:42 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Xiaoc 2023-06-13 09:04:18 UTC
Description:
I have a word file which is more 300 pages.I build libreOffice for Android, I opened this file with libreOffice on Android, and it took 35 seconds from opening to documentLoaded.
I compare it to other Android Office apps which take 1~2s to open and then dynamically render the next page, and you'll see the page number increase and load dynamically and The first View will be render. 
So I want to ask can LibreOffice optimize the opening speed of such files?

It looks like the native method documentLoad() is taking too much time.


Steps to Reproduce:
Steps to Reproduce:
1.Use Android LibreOffice Viewer
2.Open many page(more 100 pages) file(doc,docx,ppt,pptx) 

Actual Results:
from opening to documentLoaded took about 35 seconds.So Slow

Expected Results:
The loaded content is displayed first, and subsequent content is dynamically loaded.the method documentLoad() reduce the load time.


Reproducible: Always


User Profile Reset: Yes

Additional Info:
This file I'll upload to Google Drive.

https://docs.google.com/document/d/1tKz3gvELS6U92EUHl8jAxFP2egFuHcQg/edit?usp=sharing&ouid=112436450903907951628&rtpof=true&sd=true
Comment 1 Julien Nabet 2023-06-13 09:07:44 UTC
*** Bug 155811 has been marked as a duplicate of this bug. ***
Comment 3 featheredreflection 2023-06-14 07:08:39 UTC Comment hidden (spam)
Comment 4 Xiaoc 2023-06-14 09:07:34 UTC Comment hidden (obsolete)
Comment 5 Xiaoc 2023-06-18 03:25:04 UTC
Anyone who can help?
Comment 6 Michael Weghorn 2023-06-22 07:34:40 UTC
Even in the desktop version of LibreOffice, this takes about 45 seconds for me to load, so might be a general performance topic, rather than something specific to the Android version.
I'm therefore changing the component to Writer for now.

(In reply to Xiaoc from comment #5)
> Anyone who can help?

Profiling where most of the time is spent might be a good first step.
Comment 7 Xiaoc 2023-06-23 12:26:10 UTC
Thanks for reply!I will try to debug for checking methods which consume much time.However, my Linux system currently does not have enough memory to build a successful debug version, so I also provide the word file, hope you analyze together!
Comment 8 Michael Weghorn 2023-06-23 21:51:18 UTC
(In reply to Xiaoc from comment #7)
> [...] so I also provide the word file, hope you
> analyze together!

Thanks for looking into this.
Unfortunately, I don't think I'll find the time to really look into this anytime soon.
Comment 9 Stéphane Guillou (stragu) 2023-10-13 22:44:40 UTC
*** Bug 157720 has been marked as a duplicate of this bug. ***
Comment 10 eric li 2023-10-31 11:44:43 UTC
any progress for this?
Comment 11 BogdanB 2023-10-31 11:46:22 UTC
(In reply to eric li from comment #10)
> any progress for this?

If you can help with a profiling from comment 6, there could be.
Comment 12 eric li 2023-11-20 12:12:16 UTC
(In reply to BogdanB from comment #11)
> (In reply to eric li from comment #10)
> > any progress for this?
> 
> If you can help with a profiling from comment 6, there could be.

I went through the source code,,looks like every time Libreoffice would loaded and rendered all the pages of the file ,,that could be the major issue of this..How can we change it?
Comment 13 Michael Weghorn 2023-11-20 14:17:18 UTC
(In reply to eric li from comment #12)
> I went through the source code,,looks like every time Libreoffice would
> loaded and rendered all the pages of the file ,,that could be the major
> issue of this..How can we change it?

Are all pages actually rendered or is the loading of the document (parsing of the XML content etc.) what takes so much time?
IIUC, the general idea is to only render what's necessary, so if rendering for all pages is done, maybe it's possible to only request rendering of (approximately) the part that's visible?
Comment 14 eric li 2023-11-20 15:06:52 UTC
(In reply to Michael Weghorn from comment #13)
> (In reply to eric li from comment #12)
> > I went through the source code,,looks like every time Libreoffice would
> > loaded and rendered all the pages of the file ,,that could be the major
> > issue of this..How can we change it?
> 
> Are all pages actually rendered or is the loading of the document (parsing
> of the XML content etc.) what takes so much time?
> IIUC, the general idea is to only render what's necessary, so if rendering
> for all pages is done, maybe it's possible to only request rendering of
> (approximately) the part that's visible?

OKay,,pls let me know how to do this? it could be possiable to improve the open performance....btw,,if you have a file like 300Mbytes,500Mbytes..still take a lot time to load all content..I think it should be a way to read file head engouh ,and only load the necessary part of the files..


thanks
Comment 15 eric li 2023-11-20 15:34:13 UTC
(In reply to Michael Weghorn from comment #13)
> (In reply to eric li from comment #12)
> > I went through the source code,,looks like every time Libreoffice would
> > loaded and rendered all the pages of the file ,,that could be the major
> > issue of this..How can we change it?
> 
> Are all pages actually rendered or is the loading of the document (parsing
> of the XML content etc.) what takes so much time?
> IIUC, the general idea is to only render what's necessary, so if rendering
> for all pages is done, maybe it's possible to only request rendering of
> (approximately) the part that's visible?

maybe it is not the rendering issue , as usually, normal GUI framwork rendering happens when load the right pages....when I checked the logs out
 public void resetParts(){
        mContext.getDocumentPartView().clear();
        if (mDocument.getDocumentType() != Document.DOCTYPE_TEXT) {
            int parts = mDocument.getParts();
            for (int i = 0; i < parts; i++) {
                String partName = mDocument.getPartName(i);

                if (partName.isEmpty()) {
                    partName = getGenericPartName(i);
                }
                Log.i(LOGTAG, "resetParts: " + partName);
                mDocument.setPart(i);
                resetDocumentSize();
                final DocumentPartView partView = new DocumentPartView(i, partName);
                mContext.getDocumentPartView().add(partView);
            }
        }


 Log.i(LOGTAG, "resetParts: " + partName);  this line was keeping generating the logs parname will increase,,So I guess  the "part" means page...after the partname increased to the end page..the file started to be opened..
Comment 16 eric li 2023-11-22 17:23:22 UTC
(In reply to Michael Weghorn from comment #13)
> (In reply to eric li from comment #12)
> > I went through the source code,,looks like every time Libreoffice would
> > loaded and rendered all the pages of the file ,,that could be the major
> > issue of this..How can we change it?
> 
> Are all pages actually rendered or is the loading of the document (parsing
> of the XML content etc.) what takes so much time?
> IIUC, the general idea is to only render what's necessary, so if rendering
> for all pages is done, maybe it's possible to only request rendering of
> (approximately) the part that's visible?

Hi,Michael I did more test

        Log.i(LOGTAG, "====> before load");
        mDocument = mOffice.documentLoad(
                (new File(fileToBeEncoded.getParent(),encodedFileName)).getPath()
        );
        Log.i(LOGTAG, "====> after load");

what I found is this completedly libreoffice C code issue,,
below is the results
2023-11-23 01:17:54.536 29487-29735 LOKitTileProvider       com.test.paper  ====> before load

2023-11-23 01:18:23.315 29487-29735 LOKitTileProvider       com.test.paper              I  ====> after load
Comment 17 Michael Weghorn 2023-11-24 23:42:41 UTC
(In reply to eric li from comment #16)
> Hi,Michael I did more test
> 
>         Log.i(LOGTAG, "====> before load");
>         mDocument = mOffice.documentLoad(
>                 (new
> File(fileToBeEncoded.getParent(),encodedFileName)).getPath()
>         );
>         Log.i(LOGTAG, "====> after load");
> 
> what I found is this completedly libreoffice C code issue,,
> below is the results
> 2023-11-23 01:17:54.536 29487-29735 LOKitTileProvider       com.test.paper 
> ====> before load
> 
> 2023-11-23 01:18:23.315 29487-29735 LOKitTileProvider       com.test.paper  
> I  ====> after load

Thanks a lot for the analysis. This seems to match what my comment 6 says about this being similarly slow in the desktop version. (Profiling with that one might be easier.)