WaiveCar / WaiveScreen

WaiveScreen related stuff.
0 stars 0 forks source link

geofence lag #178

Open kristopolous opened 5 years ago

kristopolous commented 5 years ago

Currently the screen asks for new ads after it's done playing an ad. So here's the worst use case for this model

time(s)
 0.00 X (say 30) second Ad #1 starts playing
 0.01 Car enters geofence
30.00 -> Screen asks for new ads
30.01 Screen looks at current (as of yet un-updated) database, decides to play #1 again
30.20 <- Screen gets response with geofenced ad
60.01 -> Screen asks for new ads
60.02 Screen looks at database, sees geofenced ad, starts playing.

As in there could be asymptotically near 2 ad cycles before a geofenced ad starts playing.

kristopolous commented 5 years ago

There's a few ways to solve this:

  1. The screendisplay (engine.js) could become "smart" - know about geofences, the location, jobs associated with them, and make the decisions all on its own.
  2. The screendaemon (py) could do this and tell the screendisplay.

Regardless of the approach, unless something like the purpose of #75 is satisfied, the solutions above couldn't work. We could do something else though:

  1. Lie about the geofence by a few blocks to fix the edge problem.
  2. Lie in the sow by sending it off 1 second or so before the campaign loop is exhausted, claiming all of it played - this would allow the response to come back and the database to be updated before an ad play decision is made.

Also regardless of which approach above is used, the following likely needs to be done:

  1. Have a "consider_new_ad" event that gets triggered when the sow comes back:
  2. the engine revisits the database to see if it needs to switch
  3. if a higher-priority campaign is found then the one playing, it needs to switch.
  4. send off the partial sow for the interrupted campaign in a way that doesn't trigger a re-entry to this loop.
  5. cancel all the timers for the next asset, css animations, etc
  6. make new timers to transition to the higher priority campaign immediately