opfo / app

An iOS app for the EDA397 course made at Chalmers in the spring of 2013.
7 stars 1 forks source link

Crashing when performing [OPFQuestion all:30] #12

Closed rastersize closed 11 years ago

rastersize commented 11 years ago

When running [OPFQuestion all:30] the app becomes unresponsive and then crashes. The log is filled with the same five SQL queries. The problem seems to originate with me trying to log a OPFQuestion object to the console. The stack trace ends with:

#26 0x00012e9f in __35+[OPFModel standardDateTransformer]_block_invoke at /App/Code Stream/Models/OPFModel.m:150
#27 0x000364de in -[MTLValueTransformer transformedValue:] at /App/Pods/Mantle/Mantle/MTLValueTransformer.m:64
#28 0x0002faf3 in -[MTLJSONAdapter initWithJSONDictionary:modelClass:error:] at /App/Pods/Mantle/Mantle/MTLJSONAdapter.m:115
#29 0x0002eab0 in +[MTLJSONAdapter modelOfClass:fromJSONDictionary:error:] at /App/Pods/Mantle/Mantle/MTLJSONAdapter.m:52
#30 0x0000a45f in +[OPFPost parseDictionary:] at /App/Code Stream/Models/OPFPost.m:30
#31 0x0001321e in __17+[OPFModel query]_block_invoke at /App/Code Stream/Models/OPFModel.m:166
#32 0x000167ee in -[OPFQuery getOne] at /App/Code Stream/Utilities/Persistence/OPFQuery.m:37
#33 0x00016883 in -[OPFQuery getOne] at /App/Code Stream/Utilities/Persistence/OPFQuery.m:42
#34 0x0000d32e in -[OPFComment post] at /App/Code Stream/Models/OPFComment.m:37

and before that there is an enormous amount of calls to -[MTLModel description] at /App/Pods/Mantle/Mantle/MTLModel.m:187

And the SQL queries:

2013-04-25 18:04:25.810 Code Stream[24528:c07] Executing SQL on db baseDB: SELECT 'posts'.* FROM 'posts' WHERE ('posts'.'post_type_id' = '1' AND 'posts'.'id' = '8453008') LIMIT 1
2013-04-25 18:04:25.835 Code Stream[24528:c07] Executing SQL on db baseDB: SELECT 'comments'.* FROM 'comments' WHERE 'comments'.'post_id' = '8455413'
2013-04-25 18:04:25.841 Code Stream[24528:c07] Executing SQL on db baseDB: SELECT 'users'.* FROM 'users' WHERE 'users'.'id' = '217288' LIMIT 1
2013-04-25 18:04:25.842 Code Stream[24528:c07] Executing SQL on db baseDB: SELECT 'users'.* FROM 'users' WHERE 'users'.'id' = '245867' LIMIT 1
2013-04-25 18:04:25.843 Code Stream[24528:c07] Executing SQL on db baseDB: SELECT 'posts'.* FROM 'posts' WHERE 'posts'.'id' = '8455413' LIMIT 1

See the branch feature/search-questions-by-tags, run it and then tap the “questions” row. See the OPFQuestionsViewController class (especially row 230 through 235).

rastersize commented 11 years ago

Probably also happens for [OPFQuestion all] but that took to long to run so I stopped the process.

jesjos commented 11 years ago

There's ole weird shit going on. Specs that were succeeding are failing after I did the last merge from master. Will look into this tomorrow.

25 apr 2013 kl. 18:24 skrev Aron Cedercrantz notifications@github.com:

Probably also happens for [OPFQuestion all] but that took to long to run so I stopped the process.

— Reply to this email directly or view it on GitHub.

jesjos commented 11 years ago

I made some change to the query interfaces, are you still able to replicate this error?

tdeekens commented 11 years ago

I had this interesting bug which made my controller go completely nuts. I wanted to NSLog the OPFPost which gets passed to my OPFCommentViewController. Whenever I did the stack went completely crazy logging recursive craziness I guess.

So doing:

NSLog(@"%@", self.postModel);

caused something like:

2013-04-29 10:55:15.921 Code Stream[1997:c07] Warning: there is at least one open result set around after performing [FMDatabaseQueue inDatabase:]
2013-04-29 10:55:15.923 Code Stream[1997:c07] Executing SQL on db baseDB: SELECT 'posts'.* FROM 'posts' WHERE 'posts'.'id' = '8414113' LIMIT 1
2013-04-29 10:55:15.924 Code Stream[1997:c07] Warning: there is at least one open result set around after performing [FMDatabaseQueue inDatabase:]
2013-04-29 10:55:15.926 Code Stream[1997:c07] Executing SQL on db baseDB: SELECT 'posts'.* FROM 'posts' WHERE ('posts'.'post_type_id' = '1' AND 'posts'.'id' = '8414076') LIMIT 1
2013-04-29 10:55:15.927 Code Stream[1997:c07] Warning: there is at least one open result set around after performing [FMDatabaseQueue inDatabase:]
2013-04-29 10:55:15.931 Code Stream[1997:c07] Executing SQL on db baseDB: SELECT 'comments'.* FROM 'comments' WHERE 'comments'.'post_id' = '8414113'
2013-04-29 10:55:15.932 Code Stream[1997:c07] Warning: there is at least one open result set around after performing [FMDatabaseQueue inDatabase:]
2013-04-29 10:55:15.945 Code Stream[1997:c07] Executing SQL on db baseDB: SELECT 'users'.* FROM 'users' WHERE 'users'.'id' = '614165' LIMIT 1
2013-04-29 10:55:15.946 Code Stream[1997:c07] Warning: there is at least one open result set around after performing [FMDatabaseQueue inDatabase:]

I can only assume that a description call is recursively called but tbh I don't really now. I just don't log that model for now (。◕‿‿◕。).

Groet'n, Tobi

jesjos commented 11 years ago

It kinda makes sense in a way. A post has many comments and a comment has a post. Description probably tries to print all properties. To print post.comments, it will fetch the comments from the db. To describe each comment, is has to get the connected post. So it fetches that. And OH! I need to describe this user too! Better get all its comments... And on and on and on and on... Hm. Gunna have to think hard on this.

tdeekens commented 11 years ago

Don't worry too much I'd say. It works cool as long as you don't log that beast.

On Monday, 29. April 2013 at 11:04, Jesper Josefsson wrote:

It kinda makes sense in a way. A post has many comments and a comment has a post. Description probably tries to print all properties. To print post.comments, it will fetch the comments from the db. To describe each comment, is has to get the connected post. So it fetches that. And OH! I need to describe this user too! Better get all its comments... And on and on and on and on... Hm. Gunna have to think hard on this.

— Reply to this email directly or view it on GitHub (https://github.com/opfo/app/issues/12#issuecomment-17156212).

rastersize commented 11 years ago

“Easy fix”: Override the -description method of all models and just print what we want (and don’t print any relation) :smiley_cat:

For example:

- (NSString *)description
{
    return [NSString stringWithFormat@"<%@: %p> id = %@; name = %@;", self.class, self, self.identifier, self.name];
}
tdeekens commented 11 years ago

Oh i thought that thing was already overwritten.

On Monday, 29. April 2013 at 11:20, Aron Cedercrantz wrote:

“Easy fix”: Override the -description method and just print what we want (and don’t print any relation)
For example:

  • (NSString *)description { return [NSString stringWithFormat@"<%@: %p> id = %@; name = %@;", self.class, self, self.identifier, self.name]; }

— Reply to this email directly or view it on GitHub (https://github.com/opfo/app/issues/12#issuecomment-17156826).

rastersize commented 11 years ago

@tdeekens Na, MTLModel has a default implementation which prints the values for each property.

rastersize commented 11 years ago

The isEqual: and hash methods still trigger this crasher. @jesjos is fixing that now by overriding them.

jesjos commented 11 years ago

Fixed in 453845bbde4159336602b6574423d45988dc031c