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

The library works slow on iPhone 4 #4

Open
nyanev opened this issue Dec 19, 2012 · 13 comments
Open

The library works slow on iPhone 4 #4

nyanev opened this issue Dec 19, 2012 · 13 comments

Comments

@nyanev
Copy link

nyanev commented Dec 19, 2012

Hello,

The library is great but there is one problem. When I test it on iPhone 4 flip is very slow. I took 1 second to start the flip.

@mpospese
Copy link
Owner

Unfortunately a known issue with retina screens - 4x more pixels to be rendered and because it's from UIKit, the rendering has to be done on the main thread and is CPU-bound. If you set the shouldRenderAllViews flag to NO, that should cut the start up time roughly in half. The downside will be that the non-moving half of the page will be live (i.e. if you're content is moving/changing) then it will change during the animation.

If your content is static - i.e. you could render it as images ahead of time because it doesn't change, then you could mod the library to pass in the images to use (the "halves" of the pages) and then flip should start instantaneously.

@elsurudo
Copy link

Hi Mark,

First of all, this looks like a great library, and I'm looking forward to using it in an upcoming project.

I'll probably need to do some speed optimizations myself, similar to the author here. I was wondering if you could clear up a few things for me.

I'm not a Quartz expert by any means, but I was under the impression that a CALayer renders the view into a raster image for OpenGL to use while performing animations. If this is true, why is it necessary to manually render the page views to pass to the library? Couldn't you just manipulate the CALayer, and it should "just work"? I'm probably missing something here, but seeing as how I'll likely need to make some changes to the library, I'm interested in the design decisions.

As for rendering static content ahead of time to have an instantaneous flip start, is it possible to do that in a thread-safe manner? If so, how? Perhaps make an exact replica view off-screen, and render that one?

Looking at your code really makes me appreciate the effort Flipboard team went through! Their flips are near-instantaneous, and they can even have dynamic elements changing during the flip! Quite amazing.

@hankbao
Copy link

hankbao commented May 28, 2013

Hi, @mpospese. AFAIK, in iOS 4 and later the rendering can be done off the main thread. I'm not sure if this could help to achieve the instantaneous flipping effect. It may still be a performance gain anyway.

Hey, @elsurudo. Have you made some effects close to the Flipboard one yet? Their flipping is really smooth even on the retina iPad. I wonder how they achieve it.

@elsurudo
Copy link

@hankbao Unfortunately not. I ended up going with a UIPageViewController in the end with a page curl transition, as that is what the client preferred anyways.

The Flipboard transitions are definitely impressive, though. Their images usually aren't Retina (if I remember correctly), and they layouts are rather simple, which would definitely help with the initial rendering speed.

@mRs-
Copy link

mRs- commented Jun 13, 2013

i created a method to take screenshot after each flip animation from the viewcontroller before and after. This is really a speed up for the responsiveness

@hankbao
Copy link

hankbao commented Jun 13, 2013

@mRs- That's cool. Do you take screenshot off the main thread? If that's the case, sync main thread painting with background screenshot when performing serial fast flipping may be a problem.

@mRs-
Copy link

mRs- commented Jun 13, 2013

I added a Flag if the screenshots are done by the background process. Then i implemented a real hard hack in the MPFlipViewController to make a flip wit a pre-rendered image. If the flag is false i use the normal method to flip to the ViewController to guarantee the best user experience.

@kev52
Copy link

kev52 commented Jul 1, 2013

@mRs- can you share your modifications with us?

@mRs-
Copy link

mRs- commented Jul 1, 2013

Not at the moment but in near future it will be a good idea, i put it in my list.

@mRs-
Copy link

mRs- commented Jul 3, 2013

If you want a really smooth animation it not possible with the current state of the library. I tried to fix this but if we take screenshots there will be downsides of performance because the most common problem about this lib is, that you want to create a screenshot of a ViewController that is not existing. We have to first create the ViewController with its content and take then a screenshot. Building the ViewController and taking the screenshot together is really slow.

A better way is to create the flip effect at first time without a delay for the user and update the FlipView Layer on the bottom or top side on a background process and send it back to the main process. This will speed up the animation for the user.

The next problem is, that this is really slow to do that on the CPU so a transfer to the GPU would speed this up too. And another problem is to take screenshots for this. a normal Transform would be a real better option to boost performance on this, but i have no idea if this is easy to create or where i should start with this.

If anyone have a idea how to create a fold animation without taking a screenshot that would be really cool. I would like to implement this to create a Flipboard like user flow.

I transfered this library to UIScrollViews instead of scrolling you can flip the pages but there is the downside of creating the screenshots at all :(

@NikunjGodhani
Copy link

I have use this flipping in my project. . . and also i set shouldRenderAllViews flag to NO then also it takes time when flipping performs. How to decrease the Flipping delay. I want to increase the speed of the flip animation. Please give me solution of that problem reply as soon as possible.

Thank You in Advance

@mRs-
Copy link

mRs- commented Sep 16, 2015

The only Solution is to reduce the quality of the screenshots that are made. iPhone 4 is really slow and it's not supported by Apple any more.

Von meinem iPhone gesendet

Am 16.09.2015 um 06:05 schrieb NikunjGodhani [email protected]:

I have use the flipping in my project. . .How to decrease the Flipping delay. I want to increase the speed of the flip animation. Please give me solution of that problem replay as soon as possible.

Thank You.


Reply to this email directly or view it on GitHub.

@NikunjGodhani
Copy link

@mrs, How would i know quality of the screenshot because i used this in my project, in that xml parsing implement. so how i create the screenshot for upcoming news.

And please can you give me where is the path of that screenshot on that library.

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

No branches or pull requests

7 participants