Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Crash when calling findAllRemote in rapid succession

#39

Good morning, I ran into this while working on a project with a refresh button: when performing findAllRemote too quickly in succession there is a random crash. Some of the messages I've received are as follows:

2009-02-10 05:02:49.037 App[4259:20b] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ' -[NSDecimalNumber view]: unrecognized selector sent to instance 0x10a4d70'

2009-02-10 05:06:22.138 App[4581:20b] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ' -[NSCFDictionary view]: unrecognized selector sent to instance 0x1086fb0'

2009-02-10 05:04:29.185 App[4325:20b] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ' -[NSCFSet removeObject:]: attempt to remove nil'

2009-02-10 05:26:35.701 App[4963:20b] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ' -[NSCFString count]: unrecognized selector sent to instance 0x5361b0'

2009-02-10 05:41:55.301 objective_resource[5894:20b] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ' -[NSCFString view]: unrecognized selector sent to instance 0xa029d6a0'

To be sure this was not just an issue in my code I added a refresh button to your example app and verified the same result. I made this change available in a personal commit here:

http://github.com/adamalex/objec...

If you take this change just load the example app with some data and double-click the refresh button once or twice and you should see the crash.

I did try to implement some thread safety in my app a couple different ways but no matter what I did on my side to ensure my calls weren't stepping on each other I received the same result. Please feel free to let me know if there is any additional information I can provide, thanks very much for your time.

Reported by Adam Alexander · February 10th, 2009 @ 06:02 AM

State: resolved
Assigned to: nobody

Activity

  1. Joshua Vickery
    Joshua Vickery
    • Assigned user set to Joshua Vickery

    February 10th, 2009 @ 08:01 AM

  2. Ryan Daigle
    Ryan Daigle

    (from [dc4fe44dd1338ede2e642e86fa5da20fd22d6ec2]) [#39 Crash when calling findAllRemote in rapid succession] run the NSURLConnection in the NSConnectionReplyMode rather than the NSDefaultRunLoopMode http://github.com/yfactorial/obj...

    February 10th, 2009 @ 11:15 AM

  3. Ryan Daigle
    Ryan Daigle

    (from [949e4dc87d9e60ad1265465fa0d67874301c0786]) Revert "[#39 Crash when calling findAllRemote in rapid succession] run the NSURLConnection in the NSConnectionReplyMode rather than the NSDefaultRunLoopMode"

    This reverts commit dc4fe44dd1338ede2e642e86fa5da20fd22d6ec2.

    It looks like NSURLConnection needs to run in the default mode, or it will exit immediately. http://github.com/yfactorial/obj...

    February 10th, 2009 @ 12:29 PM

  4. Joshua Vickery
    Joshua Vickery

    This is quite the pain. It looks like the problem is with the async NSURLConnection code and events firing in the main runloop. It doesn't seem to be crash within ObjectiveResource, but rather somewhere within the SDK.

    I guess the solution is to figure out a different way to handle the async requests.

    February 10th, 2009 @ 12:36 PM

  5. Adam Alexander
    Adam Alexander

    I did run across this post from an Apple engineer which provides some sample code:

    https://devforums.apple.com/mess...

    It looks very similar to what you guys are already doing but since there are a couple minor differences, maybe that would be the key? Hope it turns out to be useful...

    February 10th, 2009 @ 01:22 PM

  6. Ryan Daigle
    Ryan Daigle

    (from [7573de144e550f23f0a6b0a1b648653581bb53b6]) [#39 Crash when calling findAllRemote in rapid succession] brilliant find Adam! using a custom run loop mode seems to take care of this problem http://github.com/yfactorial/obj...

    February 10th, 2009 @ 03:59 PM

  7. Joshua Vickery
    Joshua Vickery
    • Milestone set to ObjectiveResource 1.01
    • Assigned user changed from Joshua Vickery to jjburka

    Looks like this is fixed, many thanks to Adam.

    James, I updated Harvest to use this latest version, so it looks like it handles the background HTTP processing as we need it to.

    February 10th, 2009 @ 04:02 PM

  8. Adam Alexander
    Adam Alexander

    I can confirm that after getting the latest source the crash is completely eliminated in my local project as well! Just in case, I should point out that a side effect of this change seems to have been a reduction of the asynchronous-ness of the remote connection. I say this because it seems UI changes such as updating a status label or activating a UIActivityIndicatorView, when done immediately before calling findAllRemote, do not take effect until after the connection has completed. This is not a complaint at all, I can work around it in my code but I just wanted to point it out to you in case that had gone unnoticed.

    February 10th, 2009 @ 09:38 PM

  9. Joshua Vickery
    Joshua Vickery

    Ah yes, the original implementation kept the UI responsive while the server communication was going on, but this one doesn't.

    Still, it's probably better to have to wrap calls from the UI thread up in a "peformSelector:afterDelay:" call than to have the app blow up.

    February 12th, 2009 @ 02:21 PM

  10. Adam Alexander
    Adam Alexander

    Very true, also I forgot to mention before that I have noticed a significant performance improvement since this fix was implemented. Network operations and unit tests all seem to run much faster, so that's more good news.

    It seems there are a few different (sometimes competing) goals that would all be nice to have:

    1. Excellent performance
    2. Simple syntax for client code
    3. Responsive UI during network operations
    4. Not blowing up

    This latest commit improved #1 Performance Tests and fixed #4 add harvest sample app at the expense of #3 Update README. Like you said above, we have the option to gain #3 Update README back by sacrificing #2 Performance improvements a little. I'm going to try a few different things to see what works the best in my current project (which happens to represent a good example of a relatively standard use case for ObjectiveResource) and will let you guys know what I come up with, either in terms of client code patterns or opportunities to further update OR to give us even more of the 4 qualities above.

    February 12th, 2009 @ 03:09 PM

  11. Ryan Daigle
    Ryan Daigle

    (from [ce5e0577391c706fc2ecd6b9d61f90fef698f66d]) Merge branch 'master' of git@github.com:yfactorial/objectiveresource

    February 17th, 2009 @ 01:49 PM

  12. Ryan Daigle
    Ryan Daigle

    (from [ce5e0577391c706fc2ecd6b9d61f90fef698f66d]) Merge branch 'master' of git@github.com:yfactorial/objectiveresource

    February 17th, 2009 @ 01:49 PM

  13. Ryan Daigle
    Ryan Daigle

    (from [ce5e0577391c706fc2ecd6b9d61f90fef698f66d]) Merge branch 'master' of git@github.com:yfactorial/objectiveresource

    February 17th, 2009 @ 01:49 PM

  14. jjburka
    jjburka
    • State changed from new to resolved

    February 18th, 2009 @ 12:37 PM

  15. Adam Alexander
    Adam Alexander

    As promised (threatened?) I have come up with some additional thoughts and ideas about this and posted them to a discussion I found at oup/objectiveresource/browse_thread/thread/87393e897ae16c05/f31161c822eccfd4?hl=en#f31161c822eccfd4 since the crash reported in this ticket is already resolved. Thanks in advance for any direction you can provide =)

    March 1st, 2009 @ 02:49 PM

  16. Adam Alexander
  17. Joshua Vickery
    Joshua Vickery

    Hi Adam, I moved your comment to a new ticket: #57 async connection manager

    March 2nd, 2009 @ 07:55 AM

  18. JulietOdom34
    JulietOdom34
    • Assigned user cleared.
    • Milestone order changed from 0 to 0

    After dip into this column I get a lot on how to create articles. As a graduate, I have nevercompleted one regular assignment and always use dissertation help. What a shame! But now I have cool in writing. Thank you.

    October 1st, 2010 @ 01:45 PM

  19. Debby Smith
    Debby Smith

    First, make sure you place your test crashing code in a different place than applicationDidFinishLaunching. This is only for testing -- Crashlytics will detect crashes in your applicationDidFinishLaunching method. A good place could be a button action. There is so much to be learnt about it. So better concentrate on it rather than on writing your dissertation abstracts online.

    October 25th, 2019 @ 07:57 AM

  20. abc efg
    abc efg

    Our academic pursuits, along with a range of extracurricular activities, help in honing a child's skills and ensuring that he/she grows to be a mature and responsible citizen.

    best school in greater noida

    March 20th, 2020 @ 03:00 AM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.