CaptainSpam / geohashdroid

A Geohashing app for Android devices
Other
30 stars 6 forks source link

Non-Notification #62

Open soaring-leaf opened 7 years ago

soaring-leaf commented 7 years ago

Hi again CaptainSpam,

I know it's difficult to troubleshoot the notification system so I thought I'd let you know that I didn't get a notification today for one of my points of interest. Looking at it, I can't really see why I didn't get notified but I took some screenshots for you to look at. Let me know if you want to see any of the other settings I have set up.

screenshot_2016-11-16-12-02-41 screenshot_2016-11-16-12-02-58 screenshot_2016-11-16-12-03-36

CaptainSpam commented 7 years ago

Hrm. That's definitely within range, it looks like, and it should've notified. And presumably you have stock pre-fetching on, as the app would've warned you about it if you hadn't.

This might be confirming something I thought I've seen once in a while on my phone, where it seems that the stock pre-fetch is triggering numerous hours late (as evidenced by a notification that it's doing so suddenly popping up in the middle of the afternoon). Which is really strange, I could swear I coded it to make sure it checks around 9:30am ET every day. So, it could very well be that your phone never pre-fetched the stock for some reason.

Like you said, this is something really hard to troubleshoot, but I've got my suspicions. I'm pretty sure it's that it isn't pre-fetching stocks on-time (pre-fetching being when it checks your stored nearby locations), and I've got the odd feeling it might not be fully aware of what time zone the phone is in at boot time when it sets the initial check alarms. I'll have to run some tests, but given what I'm testing, it might be a while before I get results, I'm afraid.

Thanks for the report, though!

soaring-leaf commented 7 years ago

Yeah, when I first set it up, it warned me to have the pre-fetching option selected so that is on.

Something you said reminded me that after I got home early this afternoon, Eupeode's geohashing.info site hadn't updated for today(but I just checked and it has today's point now). It could be that GeohashDroid was able to figure out the point for today but there was some other issue with the dow opening sites. Not sure where you get your data from, but you could check that and/or see if someone (or Eupeode himself) saw any issues in getting the data earlier for today.

CaptainSpam commented 7 years ago

Well, Geohash Droid gets its data purely from stock prices, either from crox.net or peeron.org's Geohash services, then working out the hashes itself. So unless either of those are slow in getting stock data out, GHD should be ready to go shortly after the NYSE opens, and if they ARE slow, GHD will keep trying until it gets something usable.

(of course, if the sites have issues like what happened a couple months back, then GHD will be stalled out, but that's a different thing I'm working around)

I could ask Eupeode later if he had problems with today's data, but I still want to figure out why I'm getting the pre-fetch notification late in the day. I'm at least partly sure it's something in GHD that's at fault here. :-)

Thanks!

CaptainSpam commented 7 years ago

Oooo, hold on, I may have a theory. I didn't realize that Android 6.0's Doze feature messes with repeating alarms (like what I use to schedule the stock price checks). That WOULD cause it to not always trigger in the morning (EST) and delay it until some other time when the device is awake.

If I'm right, I can rethink the stock alarm system so it'll work properly with Doze, but in the meantime, here's a workaround you can try: Tell Android to allow Geohash Droid to override Doze. On stock Android, that'd be Settings > Apps > (gear icon on top) > (maybe Special Access) > Battery Optimization, set the "Not optimized" spinner to "All apps", find Geohash Droid, and set it to "Don't Optimize". GHD shouldn't be doing anything in the background besides that daily stock check, so the battery use shouldn't be an issue. And, if you do that, you can turn it off later once I've got the Doze-friendly calls in place and am sure they work.

Of course, this is going to be tricky to test, but I'm reasonably confident this is what's doing it. Never did update AlarmService to account for Doze...

Then again, if you're not using at least Android 6.0, this may not exactly be relevant.

CaptainSpam commented 7 years ago

Hm, wait. This might get a bit worse than I thought. Turns out the method I thought would help in-code still won't get a network connection if the device is in Doze. I think I've got another way to do it, if I decide to add the Firebase cloud message stuff in. Weird how that's the only way to get network access while dozing...

CaptainSpam commented 7 years ago

Okay... with a bunch of testing data, at least, I was able to get the most recent version (just published to the Play Store) to trigger the Known Location notification this morning. I think I've got it reasonably good WITHOUT having to dump Firebase into the app, which is good. Now, I know this might take a while to confirm on your end, but if you can try the latest version and let me know if you get a notification under the right circumstances, that'd help a lot.

Thanks!

soaring-leaf commented 7 years ago

Sure, I'll update the app and let you know how it goes. I don't have too many pins right now, but I can slap a few extra test pins in there so hopefully I won't have to wait too long for a hit.

soaring-leaf commented 7 years ago

ok, I set up some test pins on Friday and I think since the weekend points were already known, I got the alerts pretty much right at 9:30am. Today(Monday) I didn't and didn't open the app to see what would happen. I got the alert right around 10:00am. I'll let you know at the end of the week how the rest of the days go and if anything gets missed. I put down 5 test pins at the maximum range so the graticule is pretty well covered and I should get a hit most days.

CaptainSpam commented 7 years ago

Okay, that sounds reasonable. In code, if there's a problem fetching the day's stock (isn't posted yet, network failure, etc), it'll snooze for a half hour before trying again. If Doze was in effect around 9:30am, that would've given it a failure (I can't get any network data if Doze is active, even if the phone wakes up to handle a background task like this), so 10am would be the second attempt.

(and yep, it'll keep trying straight through to the next day if need be until it gets an answer)

I've had a few test pins on my local version, and they've been getting pings the past couple days, sometimes slightly late, but it's sounding like this may have cleared up most of the problems. I might tighten it up to a 15-minute snooze later (I can't get shorter than that, as Android won't service alarms less than 15 minutes apart in Doze), but this is good data so far.

soaring-leaf commented 7 years ago

Ok, sorry I'm a bit late here, but it's a Good News/Bad News kind of post. Good news is that despite having a couple days where I was out of the house at 9:30 am(and some missed pins altogether), I did get alerts when I finally did connect and those days that I was home/connected, I got the alerts right at 9:30 or in the next couple half hour increments as advertised.

Bad News is that since I had so many large pins set, I noticed that a couple hashes near the edges of the graticule actually overlapped two separate pins, but I only got one notification(I think I had a couple hashes hit in my main graticule that landed in an area overlapped by two pins, but that's not as bad as the following scenario).

I do have a couple pins set a number of graticules away (and one across the world) so if someone doesn't notice that their far pin gets a hit but also for some reason has a pin set that overlaps the other pin set in their, I'm assuming, last used graticule, they'll only see the alert for the close grat. I've never programmed phone apps before, but I'm thinking it would probably be easier to keep the one phone notification and once you open the app, have a second message saying you have multiple hits on known locations. If it's easy to have multiple phone notifications, that obviously would work too.

CaptainSpam commented 7 years ago

Hm... Well, what you're describing IS the intended behavior, as far as I coded it. It'll only trigger one notification per day (potentially a second one for the globalhash), and it'll focus on whichever known location was closest, leaving the rest in a "(it's also close to X other locations!)" blurb if applicable. I did that specifically to avoid potentially dumping a ton of notifications on you if lots of known locations match. Though, in hindsight I guess that might not be the best interface if you've got a lot of points in multiple graticules (i.e. if you travel a lot).

I might have to reconsider how I do notifications, then. Doing multiple notifications isn't hard at all, but it's sort of bad form to have the status bar suddenly explode with icons when you're not expecting them. Maybe a preference to make a separate notification per graticule or known location?

But regardless, that's something for later. As far as the original issue of the notifications not triggering at all, I'd say that's taken care of. Thanks for testing!

soaring-leaf commented 7 years ago

Yeah, that's a good point. You don't want your phone 'blowing up' on you. I have a couple points out where friends are in case a ridiculously easy Puppetmaster option comes up and a couple in NY that, depending on the day, I might decide to swing a long trip for. The scenario I describe is unlikely, but I was thinking worst case. I would guess most users would set up a few small close pins and would never even come close to overlapping in other grats. I should remove those large scale pins then so I don't accidentally overlap my real pins though.

Looking back at your response: "leaving the rest in a "(it's also close to X other locations!)" blurb if applicable. "

Are you saying there should be a message in the app saying there are other pins that are close or is that just in the background? If you are considering a multi-match message, I think a good compromise would still be one notification and then an in app message like the quote above just so the user knows there are other matches so they can check their other pins.

Anyway, thanks for all the work you've put in to this and indulging my ideas and concerns. No matter what you decide it's still an awesome app [and users never know what they need anyway ;) ]

CaptainSpam commented 6 years ago

Well, it took me way too long to get back to this one, but I finally did! Now there's an option in place to have it notify once per Known Location or per graticule (within a reasonable limit). That's out on the Play Store now, as well as in the Releases section of the repo. Enjoy!