-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Slowness on mobile devices #30
Comments
Try loading pages one by one in dom via ajax. It works better. |
It's a known issue, optimization for mobile devices will be done later, and, as @iapain said, might be a work of the frontend. |
This alone can make this project as a standalone super feature. Most of the pdf2html converters dont support mobile devices and most of mobile devices has inbuilt javascript based rendering mechanism which screws up the UI. It is really a nice to have feature if there's mobile support for the html's like a command line arg-- pdf2htmlEx somefile.pdf --ipad what do you guys think about this ? |
Can you elaborate what should be done, for example, especially for iphone5 ? |
Pardon me, what these options going to do? Problem is that PDF is usually fixed layout document and text won't re-flow on mobile devices, that is the core problem on small screen devices. However, I am in a favour of adding support for preset files. e.g. |
Yes, somebody asked me about this before. I've not found a trivial way to make GetOpt accepting a file as So maybe I need parse some format myself. I'll use JSON if I'm writing in Python, but how about C++? Anyway it'll be a 'user-experience' feature, but not a 'technical' Speaking of mobile devices, will it be faster if images are not included, On Wed, Oct 3, 2012 at 6:58 PM, Deepak [email protected] wrote:
|
Another obstacle is that I've got no smart phones. So no way for me to optimize/test/debug. |
@iapain btw, --fit-width might be better for you |
for presets basically which has ipad/iphone may display html content with no grey space and the page zoomed to the particular size (ipad 1024x768 for landscape and 768x1024 for portrait in viewport setting in meta tag and for iPhone <iPhone 5 will have 320x480 where as iPhone5 will have 640x1136). for scrolling iscroll js can be used to make it smoother - http://cubiq.org/iscroll simple tweaks which make this a better for use on all platforms. I hope i'm making clear of the objective and not deviating. @coolwanglu you can use some online simulations like http://quirktools.com/screenfly/ which will help you to view on simulators, its very close to a real device but its never = to a real device. |
yeah I tried --fit-width but the issue arised when turning the device to landscape and portrait mode. The grey spaces will show up when turning the devices. |
Still not clear withe the viewports. What do you expect when you rotate your device? On Wed, Oct 3, 2012 at 7:53 PM, Lalith B [email protected] wrote:
|
the pages when rotating the device must adjust to fit the screen's new width after rotation. |
I see, that sounds like a UI feature to me On Wed, Oct 3, 2012 at 7:59 PM, Lalith B [email protected] wrote:
|
@coolwanglu IMO single line key-value would be ideal for preset file e.g.
I can patch this if you want. I still don’t see it as top priority work. Regarding Mobile devices @coolwanglu problem is not exactly with width and viewports. It's more related to memory optimization in iOS which degrades some features when memory warning is received. There are quite a few tricks to make it more responsive as mentioned here. @deathlord87 Based on my tests on iPad. I have found that scrolling is very laggy, rest all works with proper zoom option. |
yes the scrolling is slow only because of the javascript. Try removing the jquery in manifest and run on iPad. Its better than the app with the jquery. i really dont understand what the javascript does. About memory warnings. It's beacause of the scrollable div area as I've read. Thats why i suggested iscroll dont know if that will work either, its all about performance. @iapain also try compiling the sources with loading the html with the following change in manifest. <!body> to <!body id="pdf-main"> It loads a bit better. I will run performance tests with instruments in mac and give some ideas of memory peaks. |
the format is ok to me, There's another concern, On Wed, Oct 3, 2012 at 8:16 PM, Deepak [email protected] wrote:
|
jquery is for selective rendering(pages outside the screen will be hidden), I think server support is necessary for the optimization you mentioned. On Wed, Oct 3, 2012 at 8:43 PM, Lalith B [email protected] wrote:
|
@deathlord87 It would be nice if you can benchmark iOS safari performance with and without hardware acceleration. You can trigger hardware acceleration simply by doing some graphic stuff in css. |
|
@contra which version are you using? If you still see this error after updating to the latest master branch, please file a new issue. |
@coolwanglu - I used the brew formula in the README |
That's not the latest version. On Friday, October 5, 2012, Eric Schoffstall wrote:
|
This should work right? http://pastebin.com/raw.php?i=iTnu2m40 |
Yes. On Fri, Oct 5, 2012 at 1:41 PM, Eric Schoffstall
|
Hey everyone, As @iapain as asked i've benchmarked the ios safari and profiled it. The memory peaks as and when we scroll the pages. Safari crashes/freezes when it reaches 14-18MB mark. When used in UIWebView (Safari View for app development) it crashes at 10+ MB loaded. The memory needs to be handled efficiently so that the scrolling is not laggy. also the page which is visible + 1 back and +1 forward pages alone should be rendered all the other pages need not be rendered. I think too many elements are the reason for crashing.
Currently when scrolling through the PDF the memory is loaded with the Full PDF and as we scroll the pages on the top is still live in memory, though Its not visible to the user. I tried with issue65_en.pdf - http://dl.fullcirclemagazine.org/issue65_en.pdf which is loaded as an example. When I reach page 6-10 Its crashing. |
@deathlord87 Thanks for your investigation. I think the only way to make work inside Safari is to write your own viewer. pdf2htmlEx does support split output. Regarding memory leaks, It might be safari bugs. I also tried to optimize and what I out that loading one page one time helps. I am not sure if we should report it to webkit. I need to further investigate about what are the limits and if hardware acceleration helps. BTW 10+ MB on scrolling is huge, @coolwanglu may it worth exploring flowable text. |
@deathlord87 Thanks a lot for your effort! You are right about the memory issue, actually there's similar things done with Javascript, where the invisible pages are hidden, for smoother scrolling on PC. @iapain issue65_en.pdf itself is 18M, and the size of converted HTML is similar, so 10+ MB did not surprise me. |
@coolwanglu the 18M is the size of the full HTML, its not necessary for the Devices be it mobile/desktop to eat up 18+ MB's of RAM for just viewing 1 page at a time. |
@coolwanglu Flowable text can dramatically ease Safari rendering problems. On the top of that the result output can fit in any screen which is equally important. |
After a quick searching, it does not seem to be as easy as I've thought of, there are many rules related to grammar, space, positions. |
@coolwanglu @bachboss with |
My mobile safari rendering issue is more the "tiling" as the render happens. In the browser the render seems fine, and the scrolling is not really an issue in either case. Can anyone suggest a preferred configuration or solution for the titling that is occurring? here is an example output file : http://russellreynolds.com/leadershift/issues/FQ2013/html/leadershift-3.html |
Bmatto's example above here is really key. Using the base.css included in his example above (see source code of http://russellreynolds.com/leadershift/issues/FQ2013/html/leadershift-3.html) makes all of my pdf2htmlEX's output work flawless on iPads and iOS devices. Probably something were changed in base.css between his output and mine using todays build of pdf2htmlEX. |
@josefnorlin Are there any issues with the current version? |
Yes, I think so. First I thought it was why this discussion started, but when I found Bmatto's example above, his html output just roared of speed. I did my best to reconstruct what he did. I tried all of the arguments I could, but it didn't change until I ran the base.css code that he used. I haven't figured out what the changes were since he did the output though. |
@coolwanglu As I read here you don't have access to smartphones and (or) iOS. I for one would happily donate a small beginning for you to buy an Android/iOS phone/tablet. As much as you've done for us with this project, I think many with me would follow (as that will probably enable even better mobile support for pdf2htmlex). How can we contribute? |
@bmatto I guess it'd be better to specify your device and browser. |
@josefnorlin Can you provide both versions (fast and slow) of your HTML file? Maybe I will be able to find some clues. Speaking of mobile devices, currently I've got only an iPad 1, which might be too slow for pdf2htmlEX. For a long time I have not tested pdf2htmlEX's output on modern devices, and I'm not sure if recent ones are fast enough. On the other hand, the lack of devices is not the main reason that I've not been able to fix this issue, there are even performance issues on PC for some PDF files! Although I've been working on it, there doesn't seems to be much progress :( Maybe it's just my lack of knowledge. I really appreciate your willingness for donation. However I'm afraid that I cannot make any guarantee at this moment, it's not like compatibility issues which are likely to be solved given enough time. On the bright side, as a start I would like to try to optimize the output at least for specific documents on specific devices. Can you please propose some devices (also browsers on them) which match your clients the best? I'll then try to pick the 'easiest' one for me as a start. |
All - To make the scrolly fun time smooth in mobile safari I used the -webkit-overflow-scrolling: touch; css property on the pageConatiner element. I will say that there was a somewhat odd side affect in that the PDF rendered in a "tiling" fashion. This tiling i'm fairly certain is a direct result of the webkit overflow action - I think they call it a "feature". I hope this helps. |
@bmatto Seems to be an interesting CSS property. Just learned. Thanks! |
Thanks @bmatto! That explains a lot. Then the performance issue with iPad Mini which I tried on is solved. And probably for many other mobile devices as well. @coolwanglu Then I guess there is no fault in base.css. But bmatto's solution would be a cool feature in the project. Great, if you have an iPad 1 already that's probably enough for testing. I'm just so thankful for pdf2htmlEX, so if there is anything you need, please feel free to ask for donations. :) As soon as our website is up I'll let you know as well. |
@josefnorlin Great. So I'll include this one and also the 3d transform property in the css file later. |
@coolwanglu Awesome! |
Thanks for the trick.. I don't know if I can help you... |
I'll give my ipad to my parents in a month as they need it. Before that I would like to test the 3d transformation rule and the If any of you would like to provide some sample PDF that might are slow on mobile devices, please post a link here, or I'll just test some random ones from my collection. |
Here are a complex example.. I have some problems when try to zoom in an out quickly on ipads..The rendering is slower than android and sometimes safari or chrome suddenly closes. Let me know when you have the sample for delete the link. |
@Toneti777 thanks! I've just downloaded the file, you may remove it now. |
I've tested a few tricks mentioned in this thread on Safari / ipad 1G Test file is demo.pdf as used in pdf2htmlEX demo., webkit-overflow-scrolling : scrolling become smoother, but the white background for each page is lost. And it makes Safari crashed a lot. removing hidden pages out of DOM: I used triggering 3d transformation: tried So I did not find any one that seems to be useful. Perhaps it depends on the document. |
@coolwanglu While researching on this topic I stumbled across preview.crocodoc.com. I viewed their test-pdf on an iphone 4S and it rendered pretty fast, scrolling and zooming did work smoothly. I wonder if you had a glimpse at their frontend-code? |
@typoheads I did read some output for PC browser, but I haven't done that for mobile browsers. |
@coolwanglu just stumbled across the slides-module of google docs: https://docs.google.com/presentation/d/1ZRIQbUKw9Tf077odCh66OrrwRIVNLvI_nhLm2Gi__F0/embed?start=false&loop=false&delayms=3000#slide=id.g30f0fc55_0_56 I poked a bit around and I noticed that they're massively using SVG for at least typo and graphics. I didn't check a slide with photos yet. |
@typoheads Indeed. There is actually an SVG backend in pdf2htmlEX, which is far from mature right now though. |
I've created a wiki page summarizing tricks that might help improving the performance on mobile devices: It's been nearly 2 years since this issue was created, and mobile technologies have changed a lot. It seems to me that most performance issues happened on iOS devices (am I right?). But I don't think I can confirm it with my iPad 1G, which lag on almost all output of pdf2htmlEX. Now the issue seems vague to me, some said it's slow, some said it's OK. Some tricks seemed to work for some PDF files, but not for others. If you have certain information for specific types of devices, please also add to that wiki page. For example SVG might be a solution, or we can just wait until devices become even faster. |
@coolwanglu et al. What a post! It's great, and the summary page it's fantastic. I just miss a short example on how to implement the last two tips: Hide pages that are out of screen using JavaScript, by completely removing them from the DOM. Regarding the last one, which I'm experimenting with it right now, I guess that if there are any transform:matrix, it should be converted to transform:matrix3d, to trigger hardware acceleration, right? |
@cdelgadob The method of removing pages would be up to the actual UI framework, so I haven't come up with a proper general example. I think a 3d transform in the outermost container would be enough, but I'm not sure. I guess you need to do some experiments. |
This problem is still happening, even with new hardware. I tested with iPad 3 and iPhone 4 and in both the scrolling is very very slow. Documents generated with --split-pages (lazy load) and without are affected. If I use -webkit-overflow-scrolling: touch in the #page-container css and documents generated without lazy load, works great. But if I use lazy load and also -webkit-overflow-scrolling: touch Safari and Chrome crash immediately. I tried to use iScroll too, I don't know if I didn't in the proper way but apparently it's not compatible with the base.css. If I remove lines bottom:0; and right:0; from #page-container the iScroll allow scroll the document, but it damages the functionality of the pdf2htmlEX viewer. Any idea how can I speed up the scrolling on iOS with --split-pages ? and why the --split-pages with -webkit-overflow-scrolling: touch crash the browser? |
I tried it on Chrome on my Samsung Galaxy Note 3, and an old Asus tablet we have, (both are Android devices) and the scrolling is very responsive for me. I tried this on a few of the pdf2htmlX demo pages, and also the documents from our in-house project. I think that given enough time, the iPads and iPhones will become more efficient in this area, similar to the Android. (perhaps the latest iPad and iPhone already are) |
I saw the original document on the safari browser on my iPad and then I tried to see the html version. its very difficult/glitchy to scroll the document (Not as smooth as the pdf rendering engine in iOS.) Can it be made more smoother with zoom controls on pinch up and pinch down ?
The text was updated successfully, but these errors were encountered: