e-mission / e-mission-transition-notify

Generate local notifications for various transitions of the finite state machine
BSD 3-Clause "New" or "Revised" License
0 stars 2 forks source link

Add support to fill in user info for the transitions #2

Closed shankari closed 7 years ago

shankari commented 7 years ago

In particular:

For the end_trip, in order to find the start point, we find the start transition and then find the point just before that. But if we don't have any start transitions, or any points before that, we take the first location point

shankari commented 7 years ago

current iOS code crashes with:

Incident Identifier: C1923CDE-75DA-44EB-9989-2CD3034E5626
CrashReporter Key:   a3512a7d781837fb1d74b7e46b3b709997d16399
Hardware Model:      iPhone7,2
Process:             emission [1058]
Path:                /private/var/containers/Bundle/Application/B741090C-2E62-43DB-8A6D-609BA0858476/emission.app/emission
Identifier:          edu.berkeley.eecs.emission
Version:             20 (1.6.0)
Code Type:           ARM-64 (Native)
Role:                Non UI
Parent Process:      launchd [1]
Coalition:           edu.berkeley.eecs.emission [745]

Date/Time:           2016-12-15 17:00:06.9066 -0800
Launch Time:         2016-12-15 16:19:51.1324 -0800
OS Version:          iPhone OS 10.0.2 (14A456)
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Triggered by Thread:  0

Application Specific Information:
abort() called

Filtered syslog:
None found

Last Exception Backtrace:
0   CoreFoundation                  0x18b2a81c0 __exceptionPreprocess + 124
1   libobjc.A.dylib                 0x189ce055c objc_exception_throw + 56
2   CoreFoundation                  0x18b2a8094 +[NSException raise:format:arguments:] + 104
3   Foundation                      0x18bd3282c -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 112
4   emission                        0x10017fda4 0x100094000 + 966052
5   emission                        0x10017f4a4 0x100094000 + 963748
6   emission                        0x10017e284 0x100094000 + 959108
7   emission                        0x10017dfa4 0x100094000 + 958372
8   Foundation                      0x18bc8d2dc -[__NSObserver _doit:] + 308
9   CoreFoundation                  0x18b24222c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
10  CoreFoundation                  0x18b241930 _CFXRegistrationPost + 400
11  CoreFoundation                  0x18b2416ac ___CFXNotificationPost_block_invoke + 60
shankari commented 7 years ago

The assertion that failed is

            NSAssert(firstLoc.ts > startTransition.ts, @"firstLocArray[0].ts (%f) < startTransition.ts (%f)",
                     firstLoc.ts, startTransition.ts);

On further investigation, this is the metadata <-> data mismatch biting us again. In particular, we search the time interval using the metadata, while we assert on the data.ts.

It is possible for there to be a mismatch between them.

Here's an example, data.ts = 1481854763.000025, metadata.write_ts = 1481854829.083308

Printing description of currTimeSecs:
(double) currTimeSecs = 1481854829.083308
Printing description of value:
{"filter":"distance","floor":0,"longitude":-122.0864741877858,"sensed_speed":0,"ts":1481854763.000025,"bearing":-1,"latitude":37.39100490234549,"vaccuracy":3,"fmt_time":"2016-12-15T18:19:23-0800","accuracy":10,"altitude":28.47171020507812}

Then, we search for entries before 1481854812.170987. As we can see, the metadata is after it, but the data is before it.

Printing description of queryString:
SELECT data FROM userCache WHERE key = 'background/filtered_location' AND write_ts >= 0.000000 AND write_ts <= 1481854812.170987 ORDER BY write_ts DESC
Printing description of (*( (double *)0x1740bf640)):
(double) _ts = 1481854763.000025
Printing description of startTransition->_ts:
(double) _ts = 1481854812.1709869

Naive option is to turn off the assert. Other options are to:

Let's first add a fuzz factor for the metadata. The earlier point that we have, the better because you can't add an incident where there is no point

shankari commented 7 years ago

Let's first add a fuzz factor for the metadata

If we add a fuzz factor for the metadata, we also need to work backwards to find the point just before the start transition. Otherwise, it is equivalent to finding the first point after the transition.