UICollectionView and SDWebImage, crash when scrolling through lot of images - objective-c

We have an app built on the iOS 10 SDK. It is presenting images in a UICollectionView and the images are loaded using the SDWebImage framework. It works well, but users have reported that the app suddenly crashes from time to time when scrolling back and forward through the images in the UICollectionView.
We have at last been able to reproduce the error on an iPhone 6 device with the mobile data connection slowed down to 3G.
What happens:
While scrolling quickly up and down through the images, quicker than they can be loaded from the server, suddenly the app crashes back to the iOS desktop. This could happen quickly, after a while, or sometimes it does not happen at all - very inconsistent.
What we have done so far:
Used instruments to check for leaks, the memory consumption is stable and lies constantly around 200Mb.
There are no calls to didReceiveMemoryWarning
We use CrashLytics to detect crashes and exceptions, nothing is logged.
The console or the debugger does not indicate any errors and no exceptions, Xcode just reports that it lost the connection to the phone when the app crashes.
Could anyone suggest an approach for further troubleshooting to nail this?
Stefan

I had a similar issue with SDWebImage. For me, it was because I let SDWebImage keep loading too many images at once. After adding
- (void)prepareForReuse
{
[self.imageView sd_cancelCurrentImageLoad];
}
the issue disappeared.

Related

Weird UIAccessibility Crash On Ipad Mini 2

Our app used Crashlytics to track app crash. One really weird crash was logged in Crashlytics. It only happened when using ipad mini. I never experienced the issue when testing on iphone 6s and iphone 6s plus.
UIAccessibility _copyMultipleAttributeValuesCallback
The following is crashlytic log screenshot.
Anything prefixed with AX or _AX is most likely a private accessibility class as well as AXRuntime is mose likely an internal framework. This means, unfortunately, that there is probably nothing you can do to fix this crash yourself.
However, filing a bug to Apple might help them resolve the issue. You can file bugs to Apple here and there is a dedicated Accessibility component that you can assign it to. Remember to include the stack trace and any other relevant information.

UIWebview loading html with large image files causes memory pressure app crash

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

webkit memory leak on page refresh?

We came across this issue while investigating low memory crashes on iOS Mobile Safari.
Most noticeably on a large HTML5 application, like a HTML5 game, we've found a memory leak on the browser where memory will keep adding up on every refresh.
In our case, the app runs with about 300MB of real memory usage and it added up around 100MB on every refresh.
Most noticeably on iPad mini and iPad4, it would crash Mobile Safari immediately after a couple of refreshes.
After a long and painful endeavour, we've found the issue being caused by a memory leak on webkit.
It happens when you use a matchMedia listener and you don't de-register the event listener before unload.
To fix it, either do not use matchMedia at all, or be sure to de-register the matchMedia event listener onunload of the page.
We've found the issue was already reported at https://code.google.com/p/chromium/issues/detail?id=113983

cocos2d mac application how to add splash screen when launching (Default.png)

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).

Localizing Xib brings strange troubles

I have an app (iPhone) with 2 Xibs that I would like to localize, but only for one Nib that has some labels to translate directly in IB. This seemed really easy until I built.
-1) The simulator suddenly did not load any of my backgrounds (UIImageViews, the same for both xib's, and programmatically modified at runtime). I did NOT change anything around this! tried delete/clean/add again, nothing changed. (debugger says it could not load the image referenced from a nib, though i changed no references an as i will say, it works on the real device)
-2) Simulator crashes (every time) and sends a report to Apple as I try to relaunch the app after modifying languages in the settings panel. As I re-build, the app runs again, the correct xibs are loaded. [edit: this happens no more if I stop tasks in Xcode, so is probably not really a bug]
-3) In the device, no crash, images are OK on background, but the english xib is loaded only.
I just can't make my way through this inconsistent behavior. Bumping my head on the wall did not solve the problem...
Tired of not finding any solution. It has to be an Xcode bug. I copied my code and recreated the app in a new project. Everything works fine but nothing changed in the content, not even a single space!
Thxs for those who took the time.