Skip to content
This repository has been archived by the owner on Mar 26, 2018. It is now read-only.

Slow BakerView and ModalView crashes on Retina iPad #1178

Open
rogerdcarvalho opened this issue Oct 15, 2013 · 11 comments
Open

Slow BakerView and ModalView crashes on Retina iPad #1178

rogerdcarvalho opened this issue Oct 15, 2013 · 11 comments

Comments

@rogerdcarvalho
Copy link

Hi,

Just discovered that running my app on iPad retina devices causes issues. My HTML relies heavily on CSS animations, which work fine on in Baker on the iPad 2/mini and also work fine on the iPad 3 within the native Safari experience. However, when opening the HTML in Baker on iPad retina, the transitions become much slower than normal and the app becomes jerky. Even worse, when Baker opens a page in the modal view, the app crashes instantly.

Version: latest commit (b618d3e)

Steps:

  • Open Baker on Retina device.
  • Open Book
  • Pages render very slow
  • Open modal view
  • App crashes

Log:

2013-10-15 21:20:29.168 Baker[422:907] ====== Baker Newsstand Mode enabled ======
2013-10-15 21:20:29.505 Baker[422:907] [BakerShelf] 'issue1' is Ready to be Read.
2013-10-15 21:20:29.518 Baker[422:907] [BakerShelf] 'issue1' is Ready to be Read.
2013-10-15 21:20:29.784 Baker[422:907] [AppDelegate] Push Notification - Device Token, review: Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application" UserInfo=0x1fd70520 {NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application}
2013-10-15 21:20:29.786 Baker[422:907] Received 1 products from App Store
2013-10-15 21:20:36.378 Baker[422:907] [BakerView] Init book view...
2013-10-15 21:20:36.379 Baker[422:907] [BakerView] Device Screen (WxH): 768.000000x1024.000000.
2013-10-15 21:20:36.382 Baker[422:907] [BakerView] Status: page 2 @ scrollIndex 0px.
2013-10-15 21:20:36.388 Baker[422:907] [BakerView] Loading book from path: /var/mobile/Applications/E9728F04-C366-479E-B79C-0AFEC2DD1C5E/Library/Caches/Newsstand/5A478927-992C-4FE3-9B8F-AEF3C9621D77
2013-10-15 21:20:36.392 Baker[422:907] [BakerView] Pages in this book: 19
2013-10-15 21:20:36.395 Baker[422:907] [BakerView] Set size for orientation: portrait
2013-10-15 21:20:36.837 Baker[422:907] [BakerView] Set size for orientation: portrait
2013-10-15 21:20:36.951 Baker[422:907] [IndexView] Set IndexView size to 768x1024
2013-10-15 21:20:36.983 Baker[422:907] [BakerView] Loading: 1.html
2013-10-15 21:20:36.984 Baker[422:907] [IndexView] Set IndexView size to 768x1024
2013-10-15 21:20:38.445 Baker[422:907] [IndexView] Set size for IndexView to 768x200 (constrained from 7790x200)
2013-10-15 21:20:41.231 Baker[422:907] [BakerView] Swiping to page: 3
2013-10-15 21:20:41.246 Baker[422:907] [BakerView] Loading: 2.html
2013-10-15 21:20:43.031 Baker[422:907] [BakerView] Swiping to page: 4
2013-10-15 21:20:43.043 Baker[422:907] [BakerView] Loading: 3a.html
2013-10-15 21:20:44.932 Baker[422:907] [BakerView] Swiping to page: 5
2013-10-15 21:20:44.952 Baker[422:907] [BakerView] Loading: 3b.html
2013-10-15 21:20:48.007 Baker[422:907] Received memory warning.

@folletto
Copy link
Collaborator

Unfortunately it seems a classic case of memory management. Retina is more than 4x intensive on the graphic side of things, thus using more memory. Once the app touches the roof, iOS just shuts it down.

There's very little we can do on Baker side. It's just optimization of the page.

(the reason why it doesn't happen in Safari is that Safari is an Apple application, thus special, and uses a faster engine that's not provided to third party apps)

Let's see however if someone else has any tip on how to optimize the pages.

@benoitchantre
Copy link
Contributor

You can find probably some answers / good practices in the session Optimizing Web Content in UIWebViews and Websites on iOS, WWDC 2012.

@benoitchantre
Copy link
Contributor

Related to issue #1068.

@rogerdcarvalho
Copy link
Author

I cant believe UIWebview is so limiting... I've tried literally everything, removed every single bit of javascript from the html, simplified all css animations, but it still crashes upon opening the modal view. The only way i can get it to not crash is to not do any animations at all, which pretty much kills the experience. Is there no memory management at all i can do to further optimize the way the view handles pages?

@rogerdcarvalho
Copy link
Author

I've done a test where I profile run the app and check memory usage. I simply open an issue, swipe to the next page, and close the issue. Then I open the issue again, and close it. I repeat this a couple of times. The overall memory usage grows incrementally (i.e. when I close the issue, the memory usage doesn't drop, and when i open it again, there is more memory used than before).

At first Baker uses less than 100 MB of memory, when I open the issue for the second time it goes above 100, and so on. I can do this for a couple of times and then after a while the app crashes (probably cause it runs out of memory). This makes me think there has to be some sort of memory leak or something not being deallocated... I expect this is why the UIWebview is so sensitive to 'fancy' HTML. Thoughts?

@rogerdcarvalho
Copy link
Author

PS - This also happens with a clean new build of Baker master and the baker framework tutorial HTML, no customisations made at all

@folletto
Copy link
Collaborator

It might be either on Baker's side or WebKit side, difficult to tell. We'll probably have to check what exactly is leaking. Thanks for the test and the report :)

@folletto
Copy link
Collaborator

We checked but we weren't able to find such a huge difference unfortunately.

At launch the master version of Baker uses about 1.7Mb, and stays around 2Mb after each open → close → memory warning cycle. We were able to find a couple of memory leaks (fixed in 6aea225) but none of these have a big impact on the overall memory consumption.

There is some kind of memory consumption increase on the modal window, but that's a weird thing we weren't able to figure out, since profiler doesn't show any leak there (or maybe there is but we need to do something different to track it).

@benoitchantre
Copy link
Contributor

@folletto when you open the modal view, the content is generally external. Does it behaves the same regarding memory consumption with local / external files? Maybe there's a cache when files are external to the app.

@folletto
Copy link
Collaborator

Yep, because it's the app consuming that memory, so it's app's consumption. It's a bit weird.

@rogerdcarvalho
Copy link
Author

strange, which device and OS did you test it on?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants