Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16201] ACS: cocoafish crashes when you execute the requests with multi-thread

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionWon't Fix
Resolution Date2017-07-26T04:15:56.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
Reporterkazuaki konno
AssigneeEric Merriman
Created2013-11-11T11:18:53.000+0000
Updated2017-07-26T04:15:56.000+0000

Description

cocoafish crashes when you execute the requests with multi-thread. According to Apple's documents, it says below. "Note: NSDateFormatter is not thread safe, so you must not mutate a given date formatter simultaneously from multiple threads." cocoa fish's class is instantiate as following; NSOperation > ASIHTTPRequest > ASIFormDataRequest > CCRequest It means cocoa fish execute in multi-thread even though it should not be. So it happens crash. [CCObject.m Line:42] NSString *dateString = [jsonResponse objectForKey:CC_JSON_CREATED_AT]; if (dateString) { self.createdAt = [[[Cocoafish defaultCocoafish] jsonDateFormatter] dateFromString:dateString]; } dateString = [jsonResponse objectForKey:CC_JSON_UPDATED_AT]; if (dateString) { self.updatedAt = [[[Cocoafish defaultCocoafish] jsonDateFormatter] dateFromString:dateString]; } We struggle to solve this problem. And we reached the following solution. NSDateFormatter *dateFormatter = [[[Cocoafish defaultCocoafish] jsonDateFormatter] copy]; NSString *dateString = [jsonResponse objectForKey:CC_JSON_CREATED_AT]; if (dateString) { self.createdAt = [dateFormatter dateFromString:dateString]; } dateString = [jsonResponse objectForKey:CC_JSON_UPDATED_AT]; if (dateString) { self.updatedAt = [dateFormatter dateFromString:dateString]; } [dateFormatter release]; I hope cocoafish will be maintained and updated.

Comments

  1. Mauro Parra-Miranda 2013-11-21

    Hello Kazuaki, can you please provide a test case for this? If you have the one that generated the logs, will be awesome. Best, Mauro
  2. kazuaki konno 2013-11-22

    Attached is test project. It will crash with iPhone4 iOS5.1.1 using Xcode5. Please set your AppKey to the project. Here is the test project. https://skydrive.live.com/redir?resid=D37D16E469EB75CA%215954
  3. kazuaki konno 2013-11-22

    Hi Mauro, Shak, I hope it will help. kaz
  4. Mauro Parra-Miranda 2013-12-04

    Hello Kaz, thanks for the testcase, I will reviewing this one and moving it shortly. Best, Mauro
  5. Lee Morris 2017-07-26

    Closing due to inactivity. If this issue still exists, please raise a new ticket.

JSON Source