I am currently working on an ios7 project that uses uiwebview. There seems to be large memory usage occurring with the use of uiwebivews, mainly we open a new view with a webview for reading mobile html news articles.
We are trying to improve the memory management as it seems that the app hits the "closed due to memory pressure"
I have implemented the memory leak prevention outlined here: http://www.codercowboy.com/code-uiwebview-memory-leak-prevention/
My question though is there a difference in memory usage when using the scrollview to scroll down the content versus just having the uiwebview's frame be the size of the content for a view?
We are currently not using the scrollview and just showing the entire page.
Embedding a UIWebView inside a UIScrollView shouldn't make any memory usage differences at all. Are you sure this is a webview issue? Have you tried making a simple app only containing a webview and pointing it at your page and seeing what happens? You may be leaking/wasting memory elsewhere in your app that needs to be cleaned up.
Related
I am building an app that has several UIWebviews all displaying various content. While testing my app, I ran into an error that said the app was terminated due to memory pressure, and I checked the console, and sure enough I had received a memory warning. Upon further testing, I noticed that this only occurs when visiting a specific page. I noticed that this page contains 2 very large image file (both 5,184px × 3,456px), which is different from the other webpages (there are about 100 and this only happens on this one page), so I think that's where the bug is. Is there a way to get UIWebview to process this and present the page, or is there no hope?
This page also puts this image into a UIImageView of size 320x320, but I don't think this is the problem because the image shows up when I go to the page, but the app crashes when I scroll down the UIWebView
I have an app with different pages, each with subviews like imageviews and button. My question is what's best to do when loading the new page. When a button is tapped on the first page a new UIView appears with different subviews. Should I remove the old page and its subviews or keep them? On the new view I have a button that should lead back to the first page, so if I would remove them when adding the new page I would have to initialize them agin.
What should I do to get it as smooth as possible?
I asked a similar question a few months ago.
Basically, the answer is :
In general, it's better to avoid doing optimizations like this until you've built your app and then profiled it to see how/where it needs improvement..
Code, get it working, and then, learn how to use Instruments, to detect where and when to optimize your app !
Good luck with iOS development.
i am migrating my iOS app onto mac. the loading time is a bit long (around 5 seconds) thus i need a splash loading screen (Just like Default.png image for iOS) but the project made from cocos2d template just shows a white screen. not sure about other apps. so is there anyway to set it?
I know that the screen size is not fixed on a mac app. but i have set a default size. and use auto scale in case of full screen mode.
EDIT:
I have tried a light weight loading scene as well but failed since the MainScene itself is light weight as well. I think the major loading time is due to the cocos2d environment set up.
In OS X a window appears when the application launches, it's not designed to use splash screens.You might want to reconsider that choice.
But if the window is still to slow to load or to display its contents, you can still do that but manually, it isn't easy like in iOS.You need to display another view inside the window until it loads.
EDIT
A little more of context: for example you can set in your xib file an image view containing the image do display.
Then you make start another thread that loads all the content that you need.After this, run a selector on the main thread that updates the window.
Based on my tests in Cocos2d 1.0.1 & 2.0 the basic Cocos2d OS X app launches really quickly.
This makes it seem pretty likely that it's something about your first scene that is taking a long time to load, or something else. Instruments can help you gather information about what your app is doing.
I suggest you make an initial lightweight cocos2d scene that will load quickly at startup and then load your second scene and transition to it. Ideally the loading of the assets for your second scene would be asynchronous (at least the ones that are slow). There are numerous blog posts on how to do this. (search for "cocos2d asynchronous loading" and you'll find many, such as this one: How to preload your game assets in a loading scene, though something more recent might be preferable).
I've implemented an iphone app with a page controller following Apple's code example. There are only 3 views on the page controller. The app works fine on normal screens, but when I test it on retina devices, there is a visible lag when scrolling either horizontally or vertically in any of the views. Any ideas of what the problem might be or how can I "debug" this?
The content of 2 of the views is a table view and on the third view I'm using CorePlot. The network is not used while scrolling.
The amount of data loaded and drawn during the scroll makes your device choking. Try to load those views in other thread using gcd and blocks.
I was adding a shadow around the 3 views and that's what was making the scrolling slow.
does it hurt performance to have multiple UIWebViews in the same screen? how do I use a busy indicator while the web page is loading and display the fully loaded page once all contents have been downloaded?
Two UIWebViews will take twice the time to render on screen. If this is a problem depends on your app and your content. Just try it.
To implement your busy indicator you could implement a delegate for your WebViews. see UIWebViewDelegate-Protocol