Tiny Core Linux
Tiny Core Extensions => TCE News => Topic started by: curaga on February 23, 2015, 02:09:30 PM
-
I wrote a PDF reader over the extended weekend. flaxpdf.tcz is posted for 6.x x86.
FlaxPDF is a fast, nice multithreaded PDF viewer for the desktop.
As long as there are more pages than cores, every core will get a workout.
Light on dependencies, trimming borders, and aggressive caching are
its major points. Okular and Evince are nice but heavy; and the point
for starting this project, ePDFview, is dead.
EPDFview was nice and light, but lacking in a couple ways:
- no caching, if you wanted to backtrack one page, it reloaded slowly
- no automatic zoom to content/trim
Now with my main PDF viewer being dead, why not build a fresh one with
those two itches scratched?
Requirements
------------
Poppler, LZO, and FLTK 1.3.
Comparison
----------
Evince 3.10.3, FlaxPDF 0.6.1 and ePDFview 0.1.8 were tested. The same
document was scrolled repeatedly to check the cpu usage, the binary size
was measured, as well as RAM use.
CPU RAM Binary
Evince 90% 56.8 MB 507 KB (evince + libpdfdocument.so)
ePDFView 72% 46.3 MB 124 KB
FlaxPDF 57% (5% *) 36.5 MB 45 KB
* To be fair to all, these measurements were done using the Vesa driver.
FlaxPDF, as the only one of the three, is able to take advantage of the GPU,
dropping its CPU use when scrolling to 5% (tested on radeon).
(http://i.imgur.com/YiAT3uJ.png)
The site is still being designed, but flaxpdf.sf.net will be the location when done.
I should note that the old XVesa cannot run this, but Xorg and the newer TinyX servers can. (Which reminds me, I really should get the tinyX builds done - currently only x86_64 Xfbdev is the new one, x86 is still shipping both old ones...)
Being an aggressively caching reader, it is not suitable for very low-RAM systems, depending a lot on the document used. Text-only documents don't use much RAM, but picture-heavy ones may easily use over 100MB.
-
very nice.
bug: canceling the file dialog triggers quit.
finally a pdf reader that uses my CPU :D
moving to page 540 of 5432 in one of my pdfs took ages.
i guess pages are rendered in sequence and for this usecase to get faster there would need to be some kind of scheduling that takes into account where we are and renders the pages around that position first.
this is with a 36MB pdf, right now VSZ is showing 1.2GB and flax is still rendering more pages :)
-
5400 pages :o
Sounds like a lot of images too, or scanned text (=images).
The pages are actually rendered in random order, decided by OpenMP.
-
Posted 0.7 that allows skipping around while big documents load.
-
Awesome! Now I can read OMAP4430_ES2.x_PUBLIC_TRM_vO.pdf faster than anyone else (pgdown).
And since it's winter here I'm fine with the comfortable excess heat :)
-
I'm not able to "Download the latest release" from the sf site with fifth, it downloads a 3kb file called "files"?
-
flaxpdf posted to the x86_64 repo
-
Must've been some temporary SourceForge issue, the link works for me?
-
FlaxPDF is awesome, highly functional and looks great too, I luv it
Thanks Curaga
-
I've improved scrolling for my use cases.
In particular I added j and k keys that scroll one view minus a couple lines like when you pgup/pgdown in opera. Also it's a bit more clever as when we're zoomed out enough j and k keys will align to the page like pgup/pgdown does.
I also fixed the pgup/pgdown buttons so that in page mode top margin isn't shown or bottom isn't cut off.
Hope you like it.
-
The behavior changes are fine, but there's some issues:
- crash when pressing page up or K on the first page
- the coding style is bad in places
- I don't understand why you divide MARGIN by the entire height in page up, did you mean to have parenthesis around floorf(yoff) + MARGIN?
I've applied the End hunk slightly edited, thanks.
-
I cannot reproduce the crash on page up, can you send me your test pdf? Does it happen right after starting the program without other preceding action?
I'll look into the other issues. I felt like there should be an easier way without converting from and to multiple relative and multiple scaled absolute units so many times, but all intuitive changes I made at first resulted in overshoot over margins or so ;)
-
It happened on bitcoin.pdf: https://github.com/benjyz/bitcoinArchive/blob/master/bitcoin.pdf
First thing after startup, no other actions needed. Though it looks like a normal "0 - 1" bug, so it should happen in every pdf.
You may want to run under valgrind in case it doesn't crash for you - under dirty memory it may not segfault immediately.
And yeah, there should be helper functions for converting between the default page-relative coordinate system and screen/data pixels, just haven't had a sudden burst of motivation when it already works ;)
edit: valgrind output confirms it's a 0-1 bug:
==16490== Invalid read of size 1
==16490== at 0x40A175: pdfview::handle(int) (view.cpp:54)
==16490== by 0x40DCA0: Fl::handle_(int, Fl_Window*) (in /tiedostot/mv/c/flaxpdf/src/flaxpdf)
==16490== by 0x421F80: fl_handle(_XEvent const&) (in /tiedostot/mv/c/flaxpdf/src/flaxpdf)
==16490== by 0x423CC6: do_queued_events() (in /tiedostot/mv/c/flaxpdf/src/flaxpdf)
==16490== by 0x4240D6: fl_wait(double) (in /tiedostot/mv/c/flaxpdf/src/flaxpdf)
==16490== by 0x40D421: Fl::wait(double) (in /tiedostot/mv/c/flaxpdf/src/flaxpdf)
==16490== by 0x40D610: Fl::run() (in /tiedostot/mv/c/flaxpdf/src/flaxpdf)
==16490== by 0x407C2C: main (in /tiedostot/mv/c/flaxpdf/src/flaxpdf)
==16490== Address 0x28091e7c38 is not stack'd, malloc'd or (recently) free'd
-
Hey, here's my 2nd version, with new trust in myself I was able to simplify and it still works.
I hope the sanitization prevents any crashes now.
edit: use scroll-impr3.patch
-
Sorry, but that's still buggy. Asking for page 4294967295 doesn't produce a NULL pointer, it produces a very big pointer. The function shouldn't try to paper over invalid arguments in any case, the caller should not call it with wrong pages (which I see you added).
The new logic is good. I still have style quips, and as pgrel cannot return negative values, it should be an u32. Maybe call it screenpixels instead?
- a space on both sides of +, -, ==, !=, and other such math operators
- a space between if and (
- a space after a cast
- moving the zoomedh line is not needed
edit: Above was for scroll2.patch, but also applies to v3.
-
hope I found all issues.
-
Applied, thanks!
Notes for the future:
- never compare floats for equality, it can fail even if they are equal
- if you'd like proper attribution in the git log, send git format-patch output instead of git diff
-
Cool, I also wondered about the float comparisons, what do you think of this?
Thanks for the feedback.
-
Hi hiro
The way you compare floats for equality is to test if their values are close enough for your application that you would
consider them to be equal. Something like this:
float CloseEnough=0.01;
if((fabs(float1 - float2)) < CloseEnough)
{
code to execute if the two floats are considered to be equal
}
-
@hiro
That's missing one parenthesis, mainly for clarity - casting happens before ==, but it's good to have the parens around in case other things get added.
Applied with the parens added.
-
Good morning , i have a little compiling problem
make[2]: Entering directory '/tmp/flaxpdf-0.7.2/src'
g++ -g -O2 -pthread -isystem /usr/local/include -isystem /usr/local/include/freetype2 -isystem /usr/local/include -fvisibility-inlines-hidden -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_THREAD_SAFE -D_REENTRANT -isystem /usr/local/include/poppler -isystem /usr/local/include -Wall -Wextra -ffunction-sections -fdata-sections -Wl,-O1 -Wl,-gc-sections -Wl,-as-needed -o flaxpdf main.o loadfile.o helpers.o view.o -llzo2 -L/usr/local/lib -Wl,-rpath,/usr/local/lib -lfltk_images -lpng -lz -ljpeg -lfltk -lXcursor -lXfixes -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -L/usr/local/lib -lpoppler -lXrender -lX11
main.o:(.rodata._ZTI12Fl_PNG_Image[_ZTI12Fl_PNG_Image]+0x8): undefined reference to `typeinfo for Fl_RGB_Image'
view.o:(.rodata._ZTI7pdfview[_ZTI7pdfview]+0x8): undefined reference to `typeinfo for Fl_Widget'
loadfile.o: In function `renderer':
/tmp/flaxpdf-0.7.2/src/loadfile.cpp:190: undefined reference to `omp_get_num_procs'
Maybe you can give me a clue
Thanks
-
Does this help:
http://tinycorelinux.net/6.x/x86_64/tcz/src/flaxpdf/compile_flaxpdf
-
Does this help:
http://tinycorelinux.net/6.x/x86_64/tcz/src/flaxpdf/compile_flaxpdf
Thanks it solved the problem and the last issue with omp fixed with -fopenmp switch
I just want to change line 188 from main.cpp to enable other fltk schemes and add icon to file browser
Fl::scheme("gtk+"); //changed to null
Fl_File_Icon::load_system_icons(); //added
-
Added the icon line, thanks. configure should have added -fopenmp, I wonder why it failed for you?
-
Added the icon line, thanks. configure should have added -fopenmp, I wonder why it failed for you?
I did it again and yes added , maybe i missed something before :-[