appirater causes defaults changed notfication from multiple threads #44

Open
jum opened this Issue Apr 19, 2012 · 4 comments

Comments

Projects
None yet
3 participants
@jum

jum commented Apr 19, 2012

Appirater uses dispatch_async to schedule work in the low priority global queue, this causes defaults changed events to be posted from multiple threads and assorted race conditions in naive apps. I would believe that this should be mentioned in the readme as it surprised me and causes some head scratching to find out where that crash came from.

@arashpayan

This comment has been minimized.

Show comment Hide comment
@arashpayan

arashpayan Jul 2, 2012

Owner

@jum, can you provide a little more clarification about the issue you ran into? I'm a little unclear on it. Thanks!

Owner

arashpayan commented Jul 2, 2012

@jum, can you provide a little more clarification about the issue you ran into? I'm a little unclear on it. Thanks!

@jum

This comment has been minimized.

Show comment Hide comment
@jum

jum Jul 4, 2012

My app was kind of naive in the past, and changes to the defaults database always happened on the main thread, thus any defaultsChangedNotification events happened on the main thread only. As soon as appirater came in to the picture, it's use of incrementUseCount (which updates defaults) via dispatch_async caused defaultsChangedNotification events to be posted on multiple threads. I had to use synchronized statements to to serialize my code in my defaultsChangedNotification handler to avoid corrupting state in my objects. It may be clear to the advanced programmer, but it is definitely a thing any newbie might stumble upon.

jum commented Jul 4, 2012

My app was kind of naive in the past, and changes to the defaults database always happened on the main thread, thus any defaultsChangedNotification events happened on the main thread only. As soon as appirater came in to the picture, it's use of incrementUseCount (which updates defaults) via dispatch_async caused defaultsChangedNotification events to be posted on multiple threads. I had to use synchronized statements to to serialize my code in my defaultsChangedNotification handler to avoid corrupting state in my objects. It may be clear to the advanced programmer, but it is definitely a thing any newbie might stumble upon.

@arashpayan arashpayan added this to the 3.0.0 milestone Nov 5, 2016

@stsandro

This comment has been minimized.

Show comment Hide comment
@stsandro

stsandro Mar 26, 2018

@jum, how exactly did you solve this problem? I recently released a new version of my app that I haven't updated in a while. I see a few crashes on -[Appirater incrementUseCount] especially on iOS 9 and 10. Haven't seen this on iOS 11. And it only occurs in the free app that has AdMob ads for monetization. I believe that AdMob and Appirater write/read to NSUserDefaults at the same time and from different threads.

Can you give me a hint how to solve this crash?

@jum, how exactly did you solve this problem? I recently released a new version of my app that I haven't updated in a while. I see a few crashes on -[Appirater incrementUseCount] especially on iOS 9 and 10. Haven't seen this on iOS 11. And it only occurs in the free app that has AdMob ads for monetization. I believe that AdMob and Appirater write/read to NSUserDefaults at the same time and from different threads.

Can you give me a hint how to solve this crash?

@jum

This comment has been minimized.

Show comment Hide comment
@jum

jum Mar 28, 2018

jum commented Mar 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment