-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cleanObjectDictionary causing crashes #871
Comments
Because it's shared between all QSObjects. You could move that in QSRegistry though.
It could, but you would lose the ability to query for an object identifier.
That's good reasons ;-). IIRC, Maybe drop the thing entirely and check performance when navigating the filesystem ? About the crash, I have absolutely no idea of what could cause that (since objects are retained when they enter the dictionary)... Maybe a weird pointer to something that isn't a real object, causing CFHash to fail ? |
Dictionary keys act a bit like a set anyway (since they enforce uniqueness). There’s nothing to stop values from being duplicates, but I wonder how often that happens. We could still get an object by its identifier, but we’d have to use a predicate or a block to filter the set. Probably faster than iterating through it, but not as fast as just getting it from a dictionary by ID.
Sounds like that’s worth a try. |
So we haven't seen a single crash related to Considering we had ~500 users on ß3926 and about 6-7 of these crash reports, and we now have 20k+ users on ß3928 without a single report... I think the stats can speak for themselves. I still think it might be worth removing the thing entirely as Etienne suggests, but at least we've reduced the number of crashes by 1 :) |
There have been quite a few log reports relating to the the above method (in QSObject.m) crashing.
I've seen these before, but have never figured out how to solve the problem.
I initially thought the
objectDictionary
was being modified whilst being enumerated over, but that would cause an exception (that's what fast enumeration would give) and I see @tiennou implemented the @synchronize {} block round this bit of code so it should be locked.This lead me to delve deeper into the code and a few things struck me:
objectDictionary
declared as a static and not an iVar?objectDictionary
be an NSMutableSet as opposed to a Dict, to avoid duplicates?cleanObjectDictionary
method seems very wasteful. Multiple reasons why:appChanged
notification callinghideMainWindowWithEffect:
in QSInterfaceController). I've fixed this so QS only attempts to close the window if it's actually open.objectDictionary
, so we're enumerating over possibly 1000s of objects for no reason. Maybe 90% of the time for me, with my testing.And upon further investigation - I see that I've left a long message in QSObject.m line 611 which would lead to the conclusion that an NSMutableSet would be much better.
So here's what I propose:
cleanObjectDictionary
method be run a lot less, or not at all (remove the method entirely)objectDictionary
an iVar NSMutableSetI'd appreciate some input, especially from @tiennou since he made the first @synchronize {} changes, and probably knows memory management a lot better than me... :)
Here are some of the crash logs we've received, for reference (multiple identical crash reports, down to the memory address and everything):
The text was updated successfully, but these errors were encountered: