Charles 3.6.4 and HAR (HTTP Archive)
Charles 3.6.4 is another minor update to the 3.6 release; it features a large number of bug fixes, including several improvements to the HAR import/export implementation. We introduced HAR import/export to Charles 3.6 and it has just gotten better (or really, in the case of the bugs, less broken). Thanks to everyone who has corresponded with me about particular issues (especially Alex Selivanov).
HAR is an archive format for HTTP requests and responses for interoperability between software packages. Adding HAR support to Charles makes it possible to capture requests in another application and import them into Charles for analysis, or to capture in Charles and export.
I’m on the lookout for interesting analysis applications that import HAR files… drop me an email if you have any you use.
Fix a sticky iPhone home button
I’ve had a sticky home button on my old iPhone 4 for many months. It wouldn’t consistently double-tap to bring up the multitasking menu, and it caused me to develop a deadly pincer-grip that made my new 4S squeal.
Yesterday, by chance, I saw my friend Tim Haines tweet about taking his wife’s iPhone into an Apple Store, where the genius went mad on the home button with an alcohol wipe. This afternoon I went to the chemist and purchased four alcohol wipes (skin cleansing alcohol wipes) that come in little paper sachets. I took one, and wiped as hard as I could on and around the home button, being sure to press it hard and long, rolling around on the button, letting the alcohol from the wipe seep into the cracks. Continue for 30 seconds.
Happily, it seems to have worked. I can now double-tap the home button consistently, and at NZ$0.20 a wipe I think it’s a no-brainer.
High bandwidth high latency performance tuning
We recently upgraded our office Internet connection to 20Mbps fibre. Interestingly, for local traffic we were seeing excellent speeds, but international connections were disappointing (1 - 3 Mbps).
In NZ we have quite a high ping to the US (where we’re primarily connecting to), and this requires a high TCP window size to be able to have sufficient data in the pipe to take advantage of the full capacity.
Our office has both Mac OS X machines and Windows 7 machines. I’ve been unable to solve the issue on the Windows 7 machines, they are currently capped at 1 Mbps.
For Mac OS X machines it’s easy to change the appropriate parameters temporarily.
First your need to calculate the appropriate value for your TCP window. Take your network speed in Mbps (eg. 20Mbps) and your typical round-trip-time in seconds (eg. 0.3s) and multiply them then divide by 8 (eg. 20,000,000 * 0.3 / 8) to get a reasonable TCP buffer size. For my example this is 750,000 which is substantially more than the default 65,536.
Try this in the Terminal (substituting your TCP window size from the calculations above):
sudo sysctl -w net.inet.tcp.sendspace=750000 sudo sysctl -w net.inet.tcp.recvspace=750000
Test it to see if you can notice a difference. We could particularly see the difference in uploads. Then to permanently enable it, edit (or create) /etc/sysctl.conf (you’ll need to sudo this) and append:
net.inet.tcp.sendspace=750000
net.inet.tcp.recvspace=750000
Thanks to Layton Duncan for confirming this was possible on Mac OS X when I was losing faith on Windows 7.
I’m still looking for how to solve this issue on Windows 7. Suggestions welcome.
For reference reading:
For bandwidth testing I used iperf on Linux, Windows and Mac OS X (jperf).
iOS 5: turn off multiple message reminders
When I hear my phone beep I read the message on the lock screen and then put it back in my pocket. I don’t need it to beep again. After upgrading to iOS 5 it’s a bit harder to find where to turn the multiple message reminders off.
To turn off multiple message reminders (iMessage) on iOS 5 open the Settings app. Choose Notifications. Scroll down and choose Messages. Scroll down and choose the Repeat Alert setting. Change this according to your attention level.
New blog
I’ve consolidated my old blog and my oldest blog into one new blog. I may post more often. I’ll definitely, maybe, post Charles Proxy release notes. I’ll sometimes post tips and tricks so that I can find them again.
Debugging Core Data SQL on iOS
You can pass a launch argument to your application from Xcode to enable debugging of SQL statements and Core Data timing to the console log.
In Xcode 4, edit your Schemes. Go to the Run phase, Arguments tab, and in the Arguments Passed On Launch area add:
-com.apple.CoreData.SQLDebug 1
You can tick this on and off as you like so you don’t have to delete it and won’t have to remember it!
Check out the book I just published of my recent trip out to Italy. Every photo was shot on the iPhone 4 using Camera+. Get it here http://campl.us/
PostgreSQL sizes of tables
select tablename, pg_size_pretty(pg_relation_size(tablename)) as data, pg_size_pretty(pg_total_relation_size(tablename)) as total from (select tablename from pg_tables where schemaname = current_schema()) as foo order by pg_total_relation_size(tablename) desc;
If you use iPhoto 8+ and Flickr then you should check out this awesome plugin. Allows for simple export from iPhoto to Flickr (including EXIF, background uploading, GPS location, videos, sets, etc, etc, etc…) Brought to you by the same madman who built Charles, Birdbrain, Mobile Fotos, etc
Simulate memory warnings on the iPhone
When debugging on the simulator you can simulate a memory warning in your code by using the Simulate Memory Warning option in the Hardware menu. But on the device it isn’t so easy, but it’s really important to have thoroughly tested your application in the presence of memory warnings.
What I do is add some code to my App Delegate to periodically send a memory warning automatically. Usually every 5 seconds, or quicker.
- (BOOL)application:(UIApplication *)pApplication didFinishLaunchingWithOptions:(NSDictionary *)pLaunchOptions {
...
[NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(simulateMemoryWarning) userInfo:nil repeats:YES];
...
}
- (void)simulateMemoryWarning {
[[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidReceiveMemoryWarningNotification object:[UIApplication sharedApplication] userInfo:nil];
}
I suggest surrounding the timer scheduling with an #if DEBUG or similar (assuming you have DEBUG=1 configured in your debug builds) so you don’t accidentally leave this in for a release build!