Skip to content
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

adding the "app launched" transition broke the android sync #9 #7

Open
shankari opened this issue Feb 26, 2016 · 2 comments
Open

adding the "app launched" transition broke the android sync #9 #7

shankari opened this issue Feb 26, 2016 · 2 comments

Comments

@shankari
Copy link
Contributor

39976,1456440668.991,ERROR,"ServerSyncAdapter : Error org.json.JSONException: Value app launched of type java.lang.String cannot be converted to JSONObject while saving converting trips to JSON, skipping all of them"
@shankari
Copy link
Contributor Author

Added by ecc8b17

@shankari
Copy link
Contributor Author

Obvious fix is to move the try/catch block into phone_to_server so that we can skip individual entries instead of skipping the whole block. But then, because we clear all entries after a successful push, the bad entries will be lost forever.

I added some code to store them into an error database instead, but before we use it, we need to unify some usercache behavior between iOS and android. In particular, we can store

but it turns out that on iOS, if we pass in something that is a string and not a wrapper, the serialization code returns an empty JSON object '{}', so we will never store invalid entries into the database.

+ (NSDictionary*)wrapperToDict:(NSObject*)obj {
    if ([self isKindOfClass:[NSDictionary class]] || [self isKindOfClass:[NSArray class]]) {
        return (NSDictionary*)obj;
    } else {
        unsigned int propertyCount = 0;
        objc_property_t* properties = class_copyPropertyList([obj class], &propertyCount);
        NSMutableArray *keys = [NSMutableArray new];
        for (NSUInteger i = 0; i < propertyCount; i++) {
            objc_property_t property = *(properties + i);
            [keys addObject:[NSString stringWithCString:property_getName(property) encoding:NSASCIIStringEncoding]];
        }
        free(properties);
        NSDictionary *dictionary = [obj dictionaryWithValuesForKeys:keys];
        return dictionary;
    }
}

We need to think carefully about the error handling here - should we drop entries at storage time, or store them into an error database or ???

If we do store them into an error database, we should have a screen that displays them and allows users to clear them. We don't want to have the data leak of storing entries that there is no way to manipulate later.

So for now, we put on storing data into the error cache. We still have the error table, and the functions that will store entries into it, but we just don't populate them, either on iOS or on android.

shankari added a commit to shankari/cordova-usercache that referenced this issue Feb 29, 2016
Before this, on android, if there was a single ill-formatted message, we used
to abort the entire sync. Now, we only skip that message. Currently, all
skipped messages are deleted at the end of the sync.

We were originally going to store skipped messages in a separate error
database. But it turns out that on iOS, we check validity at insert time, and
invalid messages are not stored in the usercache at all, which means that they
are effectively discarded.

We need to decide our error handling policy. Until we do this, we discard on
both iOS (at insert time) and on android (at upload time). We have created an
error database to store the data, but are not using it pending decision.

The issue is being tracked in:
e-mission#7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant