promet / PRAugmentedReality

iOS Augmented Reality Framework
http://praugmentedreality.com/
MIT License
606 stars 162 forks source link

DB Mutli-threading access bug #6

Open glesage opened 11 years ago

glesage commented 11 years ago

Problem when reading and writing to the DB at the same time.

Occurs during app launch, when new objects need to be saved at the same time as the old ones are being read for display.

More details: When the download of updated objects from the data site is extremely quick (for example when the data site is on the same network as the phone), the DataController wants to save new objects to the DB even before it has had time to send the old ones in the first place to the ARController... --> Clash

glesage commented 11 years ago

This bug is a little situational though... The case I am noticing it in is:

# In some ViewController that is instantly displayed when loaded (like MainViewController)
viewDidLoad() {
    Start the AR controller;
}
viewDidAppear() {
    Setup the data;
}

As the 2 virtually happen at the same time there are clashes...

glesage commented 11 years ago

This is quite tough to fix for now as the implementation is asynchronous, I cannot even implement my usual lock system:

if (db_is_busy) {
    [self performSelector:@selector(the_function) withObject:the_parameter afterDelay:0];
    return;
}

As the performSelector method cannot have a return value ):