Author Topic: very slow page turning using swf's..very high CPU time  (Read 1319 times)

bobbo

  • Newbie
  • *
  • Posts: 19
very slow page turning using swf's..very high CPU time
« on: November 14, 2009, 04:12:27 PM »
Hello , I have a sample mz3 that loads 5 swf's generated from PDFs ..... The page turning time is exorbitant and the strange thing is that when I am in IE or FF , when I have the megazine browser window active, my CPU stays around 70-90% in IE or FF whichever I am using.   As soon as I move out of that window , the CPU goes back to normal.

I suspect it has something to do with the options I used to build the swf's but can anyone explain why the cpu time is constantly high and page turning is painfully slow? Here  is a link to the sample:

http://devdigital.ctl.ca/mz/eptslow.html

PS...the jpeg image quality os bad because I tried reducing the size of the swf files thinking that might help but apparently not .

PPS if I load one of the swf's directly into a browser there is no cpu time spike so there is something happening in the megazine-flash player interaction?

Hans Nücke

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 452
  • MegaZine3 Sales Manager
Re: very slow page turning using swf's..very high CPU time
« Reply #1 on: November 15, 2009, 01:57:33 AM »
I only can confirm that this behavior is not normal!
It take 2s up to almost 4s to get one page (like edition1.swf ... edition 5.swf)
Everything else finishes in 100mm ... 500ms

And yes, computer usage is up to 60...70 %

How did you create your swf?
WHat does your mz3 look like?

Hans Nücke

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 452
  • MegaZine3 Sales Manager
Re: very slow page turning using swf's..very high CPU time
« Reply #2 on: November 16, 2009, 03:38:16 AM »
Here some hints as the result of our “off-forum" email exchange and discussion on above topic:
A combination of many things created the above reported strange behavior, which is solved now!

If you want to see (as proof ;-) a big book with >300 pages of high resolution, composed out of single swf files, working pretty smoothly (already with v2.0.2, i.e. including search support!), have a look here:
Demo Book (300 pages, with search)
And try out soom (scroll the wheel), liquid scaling (resize the window) and gallery mode with big magnification of up to factor 5 (click inside a page)!

Hopefully the following tips will help you also to achieve a fast flipping book and to adjust the parameters correctly!

Resolution, Caching
There is almost no real impact of the time it takes to show the pages and the resolution and size of the image/page (as long as the internet connection is pretty OK ;-).

Of course a lower resolution page has a positive effect on the time the first page shows up.  And also on the time it takes to fill the cache again if jumping to a page outside the cached number of pages (fast flipping across that number of pages has the same effect as “jumping”).
But since a lot of other things happens the first time a book is opened, the download time of the page is only a fraction of that time.

The next pages then are cached (you can parameterize the number of cached pages), and as long as you browse reasonably normally (read before flip to the next page without delay), the next pages should be available in an instant.
Independent on the size of the page/image, because all happens in the background.

That's why liquid scaling is such a great thing and should be preferred instead of gallery mode now (which was the only chance to “zoom” in version v1.38!).

Gallery mode still could make sense
  • in case you have a real high resolution picture and want to offer the option to see every pixel (like in the case of a 12+ MPix photo), or
  • if you have vectorized text (swf or png). Now with a zoom up to factor 5 in gallery mode you can make small fonts readable for handicapped people also on high resolution monitors.


MegaZine3 Parameters
You most probably know that a lot of things can be parameterized. A big benefit, but dangerous!
If you do not need to change the default values (which all have very meaningful settings!), it is best to not touch them. So not even list them up in the [book] declaration.
Keep it streamlined, slim.
As small as possible!
Many parameters have an impact on performance. In certain, special cases you can achieve improvements, but if you’re not very experienced, chances are high you turn it to the worse! Avoiding to play around with the parameters reduces risk of problems and keeps the file better readable! Many of the “problems” reported in this forum are results of certain “creativities”!
My suggestion is to leave all parameters at their default value first.
Only in case you have the real need to tweak/change something, and you really, really (!) want a different behavior and understood the parameter and know what you are doing, then you should touch it ;-)
But even then: please…one by one!
And check after each change, if the behavior is as expected!
Doing several changes at a time is the best way to waste time.

How to best set pagewidth and pageheight
There are several options to define heights and widths. Admitted, can be confusing at the beginning.
Hopefully the following explanations help to avoid some typical traps.

My guidance is:
Make pagewidth and pageheight in case of PDF/SWF files identical to the resolution of  your real pages; by the pixel!

Do not use any height or width parameter in neither <page> nor <img>!

Everything else results in overhead because MegaZine3 then had to scale, and every scaling takes time!

Only in very specific situations you might consider using those parameters, like defining height and width parameters for an image can help when you quickly want to put photos of "incorrect" size/dimensions into a book and cannot resize those photos at the moment (e.g. if you have no access to the sources, cannot upload because of reduced bandwidth and alike).
Then you could force with these parameters an image with whatever resolution/dimension to fit onto a page.

Be careful , though: if you pick the wrong values, you will get distorted images. Using a percentage like 50% or so in that case instead of fix values, might be the better approach.

Make the resolution of your page big enough so it is comfortably readable at full size. If 1280 pixel are needed for that, it does not really make sense to only offer 800 pixel first and with that force the visitor to use full resolution via gallery mode and hires! With all the disadvantages of the gallery mode: slow, no caching, no interaction, no page flip, … all the things you complained in the past!
With liquid scaling and zoom you now have all the power you need!
With automatic adjustment to the resolution of the visitor’s monitor.

The best approach is to either know what size your source docs are and set the book to that size, or define the book size and make your images that size.
If you know (or can safely guess) the minimum resolution of your user's screen, you also can set minscale appropriately. A good first approach is to set it to minscale="0.5" or "0.25" (see below).

If you go into full screen mode using the button in the navigation bar (not to confuse with gallery mode in full screen!!), you have maximum resolution and still can navigate and use all book features!

Liquid Scaling
This automatically is enabled whenever the parameters maxscale and minscale in the <book> declaration are set to different values.
Maxscale shouldn't be bigger than 1.0; because otherwise you see artefacts at e.g. the book edges!

Only if you have small photos and if you expect someone with a high resolution screen seeing those big enough... then you might consider to use a factor of 2.0

Minscale should be set at a value that is wither 0.5 or 0.25 to avoid waste of computing power and not to get artefacts by interpolations.

If you then zoom from min to max (the extremes, i.e. from minscale to maxscale), there is no need for any anti aliasing calculations! And Text looks sharp and clear even if presented as bitmap like jpg files (compared to vector text as in swf or png). And with the next version v2.0.2 available soon (tomorrow?!) you even can select those values with e.g. a double click (see hint in other post some hours ago).

Everything in between those values will result in fuzzy characters. That's in the nature of things, based on optics and physics and mathematics. Only with big effort you can minimize those effects (like with anti aliasing algorithms, fractal or similar technologies).


Hopefully this helps to understand the logic of Megaine3 a bit better!




bobbo

  • Newbie
  • *
  • Posts: 19
Re: very slow page turning using swf's..very high CPU time
« Reply #3 on: November 16, 2009, 02:48:31 PM »
Yes this clears up a whole bunch of questions about scaling and sizing..thank you !   The 'books' that I am working on are often pages full of small point text , so you want to allow the reader to see that text as easily and optimally as possible, with a minimum of 'dithering'.   I am trying various parameter changes based on your suggestions, ONE at a time as you also suggest.  One question, you hinted at the bottom at some new 'double click' functionality...can you elaborate for us ?

Hans Nücke

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 452
  • MegaZine3 Sales Manager
Re: very slow page turning using swf's..very high CPU time
« Reply #4 on: November 16, 2009, 04:32:41 PM »
Thank you for your reply!

First: I forgot to mention that also the parameter setting for swf2megazine is crucial. The default should work, so if you have not satisfying results using standard swf2pdf, try the swf2megazine.bat
There some parameters are already set to meaningful values.

Second: zoom click
This was a topic of another post. Dlorian gave an outlook to a feature coming with v2.0.2 and said:

MegaZine Scale (Zoom start and quick click)
In 2.0.2 there'll be two new settings: zoominit, which'll let you set the initial zoom level, and zoomdoubleclick, which allows switching between max zoom and liquid scaling (this will disable all interaction with page elements, though, because of the way Flash's double click handling works).

And, eta is either today or tomorrow for v2.0.2 ;-)

emxa2k

  • Newbie
  • *
  • Posts: 9
Re: very slow page turning using swf's..very high CPU time
« Reply #5 on: November 25, 2009, 09:47:38 AM »
...can we please have a look at the .mz3 configuration of this particular demo you demonstrate here?...it would be very helpfull to further understand some concepts...are pages in this demo .swf's or other? cause they seem to be in gallery mode and I thought this worked only for jpg's...

Hans Nücke

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 452
  • MegaZine3 Sales Manager
Re: very slow page turning using swf's..very high CPU time
« Reply #6 on: November 25, 2009, 10:57:27 AM »
sure

Code: (xml)
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!DOCTYPE book SYSTEM "megazine2.dtd">
  3. <book
  4.    plugins="console, search, gallery, keyboardnavigation, navigationbar, options, slideshow, swfaddress"
  5.    pagewidth="826"
  6.    pageheight="1169"
  7.    lang="en,de"
  8.    minscale="0.25"
  9.    bgcolor="0xffffff"
  10.    pageoffset="-14"
  11.    searchindex="wald_phd"
  12.    searchmethod="server"
  13.    searchclear="false"
  14.    galleryzoommax="5"
  15. >
  16.    <chapter>
  17.        <page buffer="true"><img width="826" height="1169" src="wald/page1.swf" hires="wald/page1.swf" gallery="pages"/></page>
  18.        <page buffer="true"><img width="826" height="1169" src="wald/page2.swf" hires="wald/page2.swf" gallery="pages"/></page>
  19.        <page buffer="true"><img width="826" height="1169" src="wald/page3.swf" hires="wald/page3.swf" gallery="pages"/></page>
  20.        <page buffer="true"><img width="826" height="1169" src="wald/page4.swf" hires="wald/page4.swf" gallery="pages"/></page>
  21. ...
  22. ...
  23. </chapter>
  24. </book>
  25.  

Gallery mode works also for swf

emxa2k

  • Newbie
  • *
  • Posts: 9
Re: very slow page turning using swf's..very high CPU time
« Reply #7 on: November 25, 2009, 11:18:49 AM »
...hmmm interesting...i have some questions though if you please...first, according to this thread, it is preferable to avoid include dimensions to every page/image and I notice that you did...furthermore, when i set such dimensions for book ( e.g. above 600 width), i can't see the page numbers to the left and right of bullets...they seem to move accordingly to my book width, so they become out of sight somehow...this DOES NOT happen to your demo...what am I missing here? (a specific attribute maybe?)...

Hans Nücke

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 452
  • MegaZine3 Sales Manager
Re: very slow page turning using swf's..very high CPU time
« Reply #8 on: November 25, 2009, 12:41:49 PM »
Regarding the size: as you see, the dimensions of the page and of the img are identical (defined in <book> for the page, and in <img> for the image).
And also identical to the size of the swf. That is the point I wanted to make: avoid any need to rescale your image, since that takes time.
And if you have to, use multiples of 2 (as divisor or dividend) to avoid aliasing problems.

There is no need for the width and height definitions in the <page> elements.
The pages hade been automatically created out of a PDF file with swf2megazine; that's why the width and height parameters are present here.

Regarding the position and behavior of the page numbers:
This is because of slightly modified ASUL files (note the maxwidth setting below):
Code: (XML)
  1.        <!-- Container for the page buttons. (out of the original navigationbar.asul) -->
  2.        <hflow name="page_buttons" height="24" anchors="(pw-w)/2,25" maxwidth="pagew*2-150" collapse_height="24" collapse_time="0.125" mouseenabled="true" style="container"/>
  3.  

Code: (XML)
  1.        <!-- Container for the page buttons. (the same lines of the modified navigationbar.asul -->
  2.        <hflow name="page_buttons" height="24" anchors="(pw-w)/2,25" maxwidth="600" collapse_height="24" collapse_time="0.125" mouseenabled="true" style="container"/>
  3.  

So no argument but changes in the ASUL file (think of ASUL like CSS style definitions!)

Hopefully this helps a bit and points into the right direction...

emxa2k

  • Newbie
  • *
  • Posts: 9
Re: very slow page turning using swf's..very high CPU time
« Reply #9 on: November 25, 2009, 01:11:38 PM »
...i see your point about dimensions (very helpful thank you)...unfortunately the modification in the asul file does not change the condition...page numbers still move accordingly to book width... :(

Hans Nücke

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 452
  • MegaZine3 Sales Manager
Re: very slow page turning using swf's..very high CPU time
« Reply #10 on: November 25, 2009, 11:47:02 PM »
OK, then I either did not chatch all changes Florian made to the ASUL or it is because a newer release (rc1 of v2.0.3) is used, sorry.

My suggestion: please wait for v2.0.3, coming our most probably still in November. The ASUL files have been enhanced, and more flexibility was added.
So there is a good chance that the behaviour will be as you need it. And/or it'll be easier to adjust.

emxa2k

  • Newbie
  • *
  • Posts: 9
Re: very slow page turning using swf's..very high CPU time
« Reply #11 on: November 26, 2009, 09:10:54 AM »
...thank you very much...I will...keep up the good work.... ;)