Uncategorized
iOS/Cocoa : Resolving deadlock caused by core data multi threading
Mar 11th
Recently when I was doing some performance fixes for an iOS app I am working on, I came across a strange issue. The app UI would freeze indefinitely without causing a crash or hitting a breakpoint. This freeze was intermittent, which made things difficult. Initially I suspected a deadlock in some new code, but I had not introduced any explicit @synchronized or semaphore wait statements in the code <which generally cause deadlocks>. All I had done is moved JSON response parsing code to a shared background queue.
On the debugger, hitting the pause button showed me that the execution was stuck in [pmutex wait] method. Quick googling of this gave me the answer I was looking for.
Cause
What had happened was that I was using Core Data abstraction for database storage and I had made a singleton class for all database methods (seems like a bad idea now). Continue reading “iOS/Cocoa : Resolving deadlock caused by core data multi threading” »
Incoming search terms:
- iOS what happen when deadlock raise (8)
- how to create multiple context in coredata in ios (2)
- multiple thread core data (2)
- save exception coredata deadlock (1)
- ios deadlocks (1)
- ios debug deadlock (1)
- ios objective c article on multithreading (1)
- ios perform fetch deadlock (1)
- iOS perform UI operation wait display done (1)
- thread safe (1)
Will Nexus 4 work well in India ? FAQ for Indian owners of LG Nexus 4
Mar 9th
UPDATE (16th May, 2013) : Nexus 4 is now officially available in India for 25999Rs
Are you thinking of buying a Nexus 4, but are skeptical whether it works well in India ? Are you worried that you can use your existing sim card like Airtel/Vodafone with your new phone ? Are you scared that you wont be able to download India-only apps on the play store ?
Then this blog post is for you. This will help you decide whether it is safe to import nexus 4 from outside India.
If you want to buy a nexus 4, read my article on how to buy nexus 4 in india.
Does Nexus 4 work well on Indian SIM cards ?
Yes it does.
See the screenshot below which shows Nexus 4 running on Airtel prepaid sim.
But the only catch is that it Continue reading “Will Nexus 4 work well in India ? FAQ for Indian owners of LG Nexus 4” »
Incoming search terms:
- does nexus 4 work in india (38)
- nexus 4 service center in india (29)
- will nexus 4 work in india (28)
- nexus 4 service center in chennai (22)
- nexus 4 service center in bangalore (20)
- nexus service center in delhi (18)
- nexus service center in india (15)
- lg nexus 4 service center in bangalore (14)
- nexus 4 work in india (14)
- nexus service center in mumbai (14)
Buy LG Nexus 4 in India for 21,500 Rs.
Mar 1st
UPDATE (16th May, 2013) : Nexus 4 is now officially available in India for 25999Rs
Here’s a story of how I managed to get my brand new LG nexus 4 phone in India for just 21500 INR.
Are you one of those people who are impatient enough to wait for nexus 4 to arrive in India? I was , and this is how I managed to get Nexus 4 in Bangalore for a cheap price. The price is so cheap that even if I sell my used iPhone 4, I would be in profit.
The order
Nexus 4 stock is available in US Google play store. But the catch is that when you try to access it from a non US IP address, this is what you get :
Sorry! Devices on Google Play is not available in your country yet.
We’re working to bring devices to more countries as quickly as possible.
Please check back again soon.
What I then tried was to use a SOCKS proxy from http://www.hidemyass.com/proxy-list/.
But when I tried using a proxy, google detected it and Continue reading “Buy LG Nexus 4 in India for 21,500 Rs.” »
Incoming search terms:
How to fix adb “device offline” issue after android 4.2.2 upgrade
Feb 17th
After I upgraded my nexus 4 to 4.2.2 I noticed that my adb stopped working (Mac). I quickly googled for the issue and I saw that many people are facing the same problem. But none of the solutions specified worked for me. After spending a lot of time trying to fix it, I finally managed to figure it out. I had almost decided to load a custom rom to make adb work, but thankfully it worked without that.
<Assuming you are running these commands in Mac/Linux>
- Goto your android sdk dir > platform-tools , and then run ./adb devices. It should show your device as offline. Only if this is the case, proceed with the next set of steps
- Run ./adb version
Android Debug Bridge version 1.0.31. If it does not show this, you might need to upgrade your adb. In my case it did show the right version, but even then adb devices shows my device as offline. - Next, try ./adb kill-server and then Continue reading “How to fix adb “device offline” issue after android 4.2.2 upgrade” »
Incoming search terms:
- adb device offline (109)
- adb devices offline (59)
- adb offline (25)
- adb device offline fix (20)
- adb error device offline (15)
- device offline adb (14)
- error device offline (11)
- adb device offline 4 2 2 (10)
- nexus 4 adb offline (10)
- Error: device offline (8)
Android contexts and singletons
Feb 15th
Understanding contexts in android correctly is every developers nightmare. This article highlights some of the findings which will help you understand contexts in android a little better. This article is more useful if you follow a singleton pattern in your app.
The general rule of thumb when using contexts is to use the activity’s context whenever possible. I would like to highlight some of the issues when I followed this rule blindly without understanding contexts correctly. In one of the projects, a lot of singleton classes were used to maintain states of different components used throughout the app. For e.g, DatabaseManager was a singleton which was a single point of entry to perform all the DB operations. Now, there are lot of developers who hate using singletons in java, because it gets abused quite a lot and make is difficult to reuse/separate components if required. Read this for more info.
Anyways, we ended up using a singleton pattern throughout our app. But some of the singletons required to use the android context for initialization. So the first thing which came to our mind was to initialize these singletons on app startup.
Mistake 1
The first mistake we did was we used Continue reading “Android contexts and singletons” »
Incoming search terms:
- what is context in android (18)
- android context (4)
- how to initialize context in android (3)
- android keep activity alive (3)
- android singleton (3)
- android keep activity alive in background (2)
- android context when is it valid (2)
- context initialization andriid (1)
- get cuureny activity from application context in android (1)
- android what happens to singletons when an app closes (1)