NSLog (or other monitoring event) within UIWebView operations - ios

I'm moderately experienced with iOS, but I'm using UIWebView for the first time on this project.
I'm wondering, is there a way to monitor the line-by-line, internal operations of a UIWebView in Xcode? Maybe drop some NSLogs in there, or some breakpoints? The delegate methods cover the pre- and post-load stuff, but there doesn't seem to be any interface to actually track what the WebView itself does when it loads a page.
Specifically, I'd like to be able to track the app's behavior as each image from a webpage is downloaded and stored. I'm getting some weird errors around an image being unusable on iOS 7, but my PHP/JavaScript swears that everything is fine on its end, and the image seems fine on desktops and on iOS 6. I'm increasingly certain that the problem has to do with the WebView itself, (an answer to a related question seems to suggest it could be about WebKit calls on different threads), and I'd love to breakpoint my way through, or NSLog some key points or something, just to rule some stuff out.
Is anything like this possible? Or is UIWebView a private party that you can only hear about once it's over?

Does it break in Mobile Safari or only in your app?
You can point Safari's web inspector on OS X at Mobile Safari running in the iOS simulator or even on an iOS device (it has to be enabled in settings).
This will allow you to view all the HTTP headers and so on.
Another option is to use something like wireshark to monitor TCP traffic, but that's a lot more complicated.
http://webdesign.tutsplus.com/tutorials/workflow-tutorials/quick-tip-using-web-inspector-to-debug-mobile-safari/

Related

How to quit iPhone webapp programmatically

I want to make a couple buttons on my iPhone to control my stereo. I thought I might be able to do this by putting a couple webpages on my homescreen that issue stop, play, next, etc requests to my media server that quit shortly after being opened. Is there a way to tell safari to quit other than crashing it? If not, what's the best way to crash safari? I realize this isn't very elegant, but I really want to have buttons on the homescreen, not in an app, and this was the best solution I could come up with.
I realize I could make the buttons native apps, but I don't want my iPhone running any third party software, even from myself (I have very little iOS programming experience, and even though I'm pretty sure there's a lot of sandboxing/this is trivial, I'm worried I'll mess up my phone). If you think I shouldn't worry about that and think it would be better to make these buttons native applications, or have any other suggestions, please let me know.
Not only is there no need for your web clips to be closed - just issue the command once - crashing Safari is a bad idea at best.

iPhone app Debug Is very fast but (Adhoc and appstore) Release is very slow

Does anyone know of any potential causes of chuggy slowness through out an iPhone app, as a result of some kind of config or third party library in the release version of an app?
I have libTestFlight, libGoogleAnalytics, libBlitFeedback, MKNetwork as well as Bolts, NewRelic, Parse and the Facebook SDK... everything else is a standard iOS SDK library.
When I build for Debug, she runs lightning fast... I simply change to 'archive' and release the app on test flight and walah it runs like a piece of crap.
I use images heavily which are all generally loaded by using "UIImageView+WebCache.h" and the SDWebImage package https://github.com/rs/SDWebImage.
I'm just in the process of elimation at the moment as the app never used to run chuggy, but I made a lot of changes in the space of a week which were all intended to make the app smoother and faster.
An example use case is:
User opens App.
Table View loads cells with images and text.
Network call updates data.
User taps tab bar to change to a UICollectionViewController. It reloads.
User taps Profile VC, it refreshes some data.
In Debug... this use case is lightnining fast, transitions smooth and quick on iPhone 4 or 5
In Release mode.. Tapping on the tab bar takes 3 seconds to transition. Scrolling is clunky in the tableview or collection view.
In answer to my own question, the reason was the result of dropping this particular piece of code in my release target.
https://gist.github.com/steipete/5664345
And more precisely this piece of code #define PROPERTY(propName) ##propName:
// Compile-time selector checks.
if DEBUG
define PROPERTY(propName) NSStringFromSelector(#selector(propName))
else
define PROPERTY(propName) ##propName
endif
Was found to be the cause of our problems only discovered by using profiler and realising that it was just soaking up the available CPU cycles. iPhone 4 was so slow it basically was unresponsive.
Anyway, the generic answer is to profile your app to see whats slowing the CPU down.

Web page not loading properly on iPod 5

In our app we've got an ordinary UIWebView showing a web page. And it works perfectly on any type of device except iPod 5. When being executed on that device the page is showed just partly, without images, just few lines of text and that's it. The more interesting is that the same thing happens even if you open this page in Safari on this iPod. We've already tried using different types of NSURLRequestCachePolicy and also using custom NSURLCache objects but all in vain. Can anybody suggest a solution?

What changes must be done to use the blackberry application code to work on Blackberry touch?

Hi I have been working on a blackberry app and developed about 90% of the app .But my client wants the app should work on blackberry touch also. So I just wanted to know what changes I will need to do to convert the same code to work on blackberry touch .Please help me I am new to Blackberry app development .
Just to confirm, we are talking about a Java application running on BB7 or earlier OS.
The short answer is, it depends.
If you have used standard RIM controls (buttons, ObjectChoiceField etc.) then these will work on the touch screen with no change. If you have used your own controls, for example an image button, then these might not work very well - for example the button might not be big enough to be hit easily with a fat finger.
The other problem is the virtual keyboard, it may appear at points when you do not want it to and not appear when you do. Not a problem on a lot of phones, but remember there are at least 2 non keyboard phones out there, so the Virtual keyboard is the only option for typing.
The best approach is work through each of your screens and try them in the Simulator. Zoom the Simulator so that it looks like the real device. And pretend you are using a finger, don't rely on the mouse because you can position the mouse very accurately.
I would raise new questions about specific Fields that you have problems with, rather than continue this with any issues you find.

iPad Limitations on Canvas Tag; Webpage Crashses on Canvas Tag Animation

Does anyone know if the iPad has any limitations on the canvas tag?
Currently I'm working on a creative that uses a flipbook and audio tag combination to simulate inline video content. The animations are drawn to the canvas element and synced with the audio content being played. There are 4 short video clips that get played when someone clicks on the four buttons below.
http://cs.sandbox.millennialmedia.com/~tkirchner/rich/K/kungfupanda2_test/
The problem I'm having though is in iPad. After playing a few animations, mobile safari just suddenly crashes. It never happens when I play it on my iPhone but it happens every time on the iPad. Its not one particular animation either because if I click a different combination of buttons, the previous clip that it crashed on plays fine, and then it decides to crash on another clip.
I think the problem might have to do with the amount of memory Safari gives individual page views. I found a blog post that explains that problem pretty well.
http://roblaplaca.com/blog/2010/05/05/ipad-safari-image-limit-workaround/
According to that post, once mobile Safari reaches a particular threshold of memory, images begin to return blank. This is consistant with my finds so far. The iPad that I'm testing this all on is running iOS 3.2.1 (and before anyone tells me that I should just explain to my boss that nobody uses 3.X anymore, I tried... they still want me to investigate this). I borrowed a co-workers iPad running iOS 4.2.1 and that device didn't crash, but some of the images weren't being drawn to the canvas.
I'm pretty sure its a problem with the canvas tag too, because I tried experimenting with running the animation without drawing anything to the canvas element, and the page never crashed.
Thats why I think maybe its a limitation with Safari's support of the canvas tag. Of course, I'm open to anybody else's suggestions.
Feels kinda weird answering my own question again, buuuut I figured if anyone did a search on this kind of question, an answer would be helpful.
I believe my original hypothesis was correct. The total amount of images that the aniamtions were using was around 600+. I think the older iPad loaded as many as it could and then when it ran out of cache and the canvas tag was trying to draw images that weren't really there anymore, it crashed.
Eventually we ended up serving the ad to devices with iOS 4.2 and higher, since the problem didn't seem to occur on those newer devices. Plus, we compressed the image sizes further, so that helped reduce the amount of images we were storing into memory.
If anybody knows approximately what the cache threshold in iOS 4.2 or higher browsers are, I'd appreciate it if you commented. Just want to get an idea of how many KB of image data I can safely load.

Resources