cagnulein / qdomyos-zwift

Zwift bridge for smart treadmills and bike/cyclette
https://www.qzfitness.com/
GNU General Public License v3.0
426 stars 116 forks source link

[BUG] Strava Upload Not Correct on Consecutive Peloton Classes #745

Closed rstrick9 closed 2 years ago

rstrick9 commented 2 years ago

Describe the bug QZ uploads Peloton workout to Strava with only "Ride #QZ", no detailed class name, instructor etc. when not closing & reopening app between stacked classes.

To Reproduce Steps to reproduce the behavior:

  1. Connect QZ to bike.
  2. Complete class, hit Stop on QZ when finished with class.
  3. Go back to tiles screen, QZ shows stopped & not running while class is not playing on device. Prior class title shows beneath Start/Stop buttons.
  4. Wait 30sec - 2min between classes
  5. Start next class on Peloton app. QZ updates class title beneath Start/Stop correctly.
  6. Complete class, hit Stop on QZ. Post-class charts populate data correctly, but title on charts only shows "Ride" & uploads to Strava as "Ride #QZ"

Expected behavior Would like to be able to run back-to-back classes with proper upload to Strava. Having to fully quit QZ, restart, wait for bike to reconnect between classes, just to have proper uploads adds unnecessary time & complication to session.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Append a debug log Attached.

Additional context In screenshot, notice March 22 5:55am class uploaded correctly, but next class at 6:18am uploaded without details and same with 6:33am class.

debug-Tue-Mar-22-06-39-02-2022.log image_3

cagnulein commented 2 years ago

thanks @rstrick9 this log starts from 06:39:03, do you have other logs? probable the one before this one

rstrick9 commented 2 years ago

I don't have any prior to that, since that was the first after enabling the debug log. I can recreate the issue with my next session and send a debug from that, if that would help?

cagnulein commented 2 years ago

yes @rstrick9 thanks! debug log are generated from the next session after the activation. This explaining why you don't see the releated log.

rstrick9 commented 2 years ago

Figured that was the case, but didn't know if what would help is in the one I did have. I've got later logs now, but I've been quitting to get proper upload as described. Would you like me to do a consecutive class session to recreate the issue then send a log of that?

cagnulein commented 2 years ago

yes please it's the only way to understand the issue thanks

rstrick9 commented 2 years ago

Will do!

rstrick9 commented 2 years ago

Okay, here's some additional screenshots & debug from a consecutive class section.

Class 1: 20min Rock Ride Class 2: 5min Post-Ride Stretch Class 3: 10min Core

Class 2 & 3 both showing just "Ride" in the chart screen & on Strava.

Thank you!

debug-Wed-Mar-30-06-48-14-2022.log image_4 Wed Mar 30 06-28-24 2022 Wed Mar 30 06-34-49 2022 IMG_2956 IMG_2957 IMG_2958

rstrick9 commented 2 years ago

Timestamps in that debug look like after the session, might have been the backup. Here's the debug starting at 6:04am debug-Wed-Mar-30-06-04-41-2022.log

cagnulein commented 2 years ago

@rstrick9 i got your issue thanks to your log! The problem is that i'm clearing strava and chart name and description when you hit start on QZ. So in the log is very clear that you're pressing start for the 2nd and the 3rd workout AFTER the peloton workout start trigger.

I'm quite sure that if you do these steps in this order it should work 1) start qz and do a workout 2) press stop at the end 3) go back from the charts view 4) press start and then pause 5) start the peloton workout in the peloton app 6) press play on qz 7) finish the workout and press stop

in this way you will have the strava and charts correctly

let me know. If this works, we should think how to fix this for everybody. Let me know

rstrick9 commented 2 years ago

Will do, I'll give that a try and let you know if it works properly!

In thinking about the trigger, would it have anything to do with how the 5min stretch & other strength type classes don't have the prompt that comes up to follow the Peloton class resistance like the cycling ones do?

cagnulein commented 2 years ago

In thinking about the trigger, would it have anything to do with how the 5min stretch & other strength type classes don't have the prompt that comes up to follow the Peloton class resistance like the cycling ones do?

hah yes, you're not seeing the popup because they don't contain metrics to share. Let's see if my steps are working, and then we will think about a full solution

rstrick9 commented 2 years ago

Hey Roberto,

Looks like those steps worked correctly! Proper uploads today without having to exit the app.

One thing I noticed is that hitting Stop after a workout on the app doesn't stop HR recording on the Apple Watch app. With that, there's a QZ "workout" written into Apple Workout for the entire session with continuous HR data. When stop/starting on the watch, the QZ written workout then matches the Peloton written workout. See the screenshot from Today vs Wednesday.

I don't think it's a big deal, just an observation. Is there anything to do about this, or anything you're working on?

IMG_2969 IMG_2970 IMG_2971 image_5

cagnulein commented 2 years ago

Looks like those steps worked correctly! Proper uploads today without having to exit the app.

Great!

One thing I noticed is that hitting Stop after a workout on the app doesn't stop HR recording on the Apple Watch app.

Yes, this it by design. I have in the todo list to sync the start/stop from the phone app to the watch app and viceversa

so know that the path is well know, should I change something in order to prevent the original issue, or do you think that's enough to know this?

rstrick9 commented 2 years ago

I think if a user will be doing back to back classes, it may be simpler if the first press of the Start/Pause button after Stop would activate the proper trigger to recognize the class rather than having to hit Start, then Pause, then Start again for the next class to pull info correctly.

It's not a huge problem, but could be a big quality of life improvement for others who don't realize that's what needs to be done and instead just quit/reopen the app (like me lol!).

What are your thoughts on something like that?

cagnulein commented 2 years ago

@rstrick9 I agree with you, I'm only worried about the right mod that I need to do in order to fix. Let's recap the actual scenario:

Maybe I can do this: if the user press start when the peloton workout is IN PROGRESS, i don't erase the strava/chart variables. What do you think? It should cover your scenario, i don't know if it could be a regression for someone else. Maybe it' something that we should post on the facebook group.

Let me know your thoughts

rstrick9 commented 2 years ago

I think it would be worth asking on the FB page if anyone else was doing the same steps I was because we didn't know better. If there's a good number who were, maybe we can try to workshop some sort of fix. Like you said, I wouldn't want to try to fix something and have it be a step backward instead of an improvement.

In your suggestion, if start is pressed when in progress, how would that affect the charts & Strava upload if the variables aren't erased? I know the chart jpgs from the QZ saves don't have the workout title in the image, so that wouldn't affect much in terms of manual upload if desired.

cagnulein commented 2 years ago

I think it would be worth asking on the FB page if anyone else was doing the same steps I was because we didn't know better. If there's a good number who were, maybe we can try to workshop some sort of fix. Like you said, I wouldn't want to try to fix something and have it be a step backward instead of an improvement.

Yes absolutey 100% agree. Could you please post about this yourself? Since i'm not a peloton user and your english is better than mine, you're the best person to talk about this on the group :)

if start is pressed when in progress, how would that affect the charts & Strava upload if the variables aren't erased

QZ will keep the name/instructor of the in progress ride and it will use when it will upload to strava/charts

Just to make clear Scenario with the actual version of QZ

Scenario with my solution

Scenario with my solution in a different contest

what do you think?

I know the chart jpgs from the QZ saves don't have the workout title in the image, so that wouldn't affect much in terms of manual upload if desired.

exactly, but it will be nice to rename this with also the peloton workout and instructor (maybe we can open a new task when this it will be fixed)

cagnulein commented 2 years ago

@rstrick9 i did the modification. It was very easy. It will be in the 2.10.60 send me an email to roberto.viola83 at gmail.com indicating this ticket and indicate that you're on iOS. I will send you the beta, Thanks

rstrick9 commented 2 years ago

@cagnulein Sent!

Would you like me to put the workaround steps on the FB post for now to help the users out, but let them know a more permanent fix is being tested? Or just leave it as is?

cagnulein commented 2 years ago

@rstrick9 great, i will try to build it in 3 hours or so. i guess we should test the solution and do a post later to show the new behavior. what do you think?

rstrick9 commented 2 years ago

@cagnulein Works for me, take your time. I'll be happy to test it out once you have it built so we can ensure proper functionality.

rstrick9 commented 2 years ago

@cagnulein Hey Roberto, so I haven't done 2 consecutive ride workouts to test the fix yet (I'm in the middle of a strength program and only had yesterday & today to finish the classes for the week), but will try that tomorrow.

I noticed something odd in today's use of the app though. I was on the beta you sent yesterday, and everything was correct, but today it wasn't pulling any charts once stopping after a class. It just had a blank white screen with no info where the charts would show after hitting stop. I've included both debugs below for reference.

I know they both say Wed, but the 6-07-02-54 log is what wrote at the end of my session today, and the 6-05-55-51 was at the end of yesterday. Let me know what you find, I'm curious.

debug-Wed-Apr-6-07-02-54-2022.log debug-Wed-Apr-6-05-55-51-2022.log

cagnulein commented 2 years ago

@rstrick9 did you leave QZ always on foreground?

cagnulein commented 2 years ago

@rstrick9 thanks for the logs, it's very clear why you don't see the charts.

These lines are available only in the file 5-55-51 (the one where you saw the charts, isn't it?). @p3g4asus i guess the only reason why this is happening it's about the fact the webserver is down?

Wed Apr 6 06:07:44 2022 1649239664151 Debug: /Users/cagnulein/qdomyos-zwift/src/webserverinfosender.cpp void WebServerInfoSender::processTextMessage(QString) "Message received:" "{\"msg\":\"getsettings\",\"content\":{\"keys\":[\"ftp\",\"age\",\"heart_rate_zone1\",\"heart_rate_zone2\",\"heart_rate_zone3\",\"heart_rate_zone4\",\"heart_max_override_enable\",\"heart_max_override_value\"]}}"
Wed Apr 6 06:07:44 2022 1649239664151 Debug: /Users/cagnulein/qdomyos-zwift/src/webserverinfosender.cpp void WebServerInfoSender::processTextMessage(QString) "Message received:" "{\"msg\":\"getsessionarray\"}"
Wed Apr 6 06:07:44 2022 1649239664609 Debug: /Users/cagnulein/qdomyos-zwift/src/webserverinfosender.cpp void WebServerInfoSender::processTextMessage(QString) "Message received:" "{\"msg\":\"savechart\",\"content\":{\"name\":\"power\",\"image\":\"data:image/png;base64,....

also @rstrick9 this shouldn't have effects on strava, isn't it?

rstrick9 commented 2 years ago

@cagnulein The Strava uploads were perfect, just the charts didn't populate on today's sessions. I wanted to let you know in case it was a bug rolled into the new update, but if it's a server-side issue that makes sense

cagnulein commented 2 years ago

@rstrick9 no, it's not server side! :) QZ has a local web server for rendering the charts :) Probably there is a bug and sometimes is offline. We have to understand this for sure before publishing the new version. Thanks for the feedback, i will try to understand it and maybe I will send you a new one with some more debug log about the webserver

rstrick9 commented 2 years ago

@cagnulein Sounds good, just let me know how I can help!

p3g4asus commented 2 years ago

@rstrick9 thanks for the logs, it's very clear why you don't see the charts.

These lines are available only in the file 5-55-51 (the one where you saw the charts, isn't it?). @p3g4asus i guess the only reason why this is happening it's about the fact the webserver is down?

Wed Apr 6 06:07:44 2022 1649239664151 Debug: /Users/cagnulein/qdomyos-zwift/src/webserverinfosender.cpp void WebServerInfoSender::processTextMessage(QString) "Message received:" "{\"msg\":\"getsettings\",\"content\":{\"keys\":[\"ftp\",\"age\",\"heart_rate_zone1\",\"heart_rate_zone2\",\"heart_rate_zone3\",\"heart_rate_zone4\",\"heart_max_override_enable\",\"heart_max_override_value\"]}}" Wed Apr 6 06:07:44 2022 1649239664151 Debug: /Users/cagnulein/qdomyos-zwift/src/webserverinfosender.cpp void WebServerInfoSender::processTextMessage(QString) "Message received:" "{\"msg\":\"getsessionarray\"}" Wed Apr 6 06:07:44 2022 1649239664609 Debug: /Users/cagnulein/qdomyos-zwift/src/webserverinfosender.cpp void WebServerInfoSender::processTextMessage(QString) "Message received:" "{\"msg\":\"savechart\",\"content\":{\"name\":\"power\",\"image\":\"data:image/png;base64,.... also @rstrick9 this shouldn't have effects on strava, isn't it?

If the above log lines are not in the log file, it means that, for some reason, the web server was down or did not receive the command messages. It would be important to know if QZ was kept in foreground or put in background anytime during workout session. If it happens again, it would be important wait a minute after the end of the session with the chart window open to see if graphs would show later.

cagnulein commented 2 years ago

@rstrick9 did you leave QZ always on foreground?

rstrick9 commented 2 years ago

@cagnulein Yes, the app stayed on & open the whole time as far as I remember

cagnulein commented 2 years ago

@rstrick9 ok thanks, i'm building a new version with some more debug log. I will let you know when i'm ready

cagnulein commented 2 years ago

@p3g4asus digging into the no-working log a bit more i also found these

Wed Apr 6 07:02:54 2022 1649242974994 Debug: /Users/cagnulein/qdomyos-zwift/src/webserverinfosender.cpp virtual bool WebServerInfoSender::init() "WebServer listening on port" 57655 " " QHash(("chartjs", ":/inner_templates//chartjs")) Thu Apr 7 06:07:45 2022 1649326065695 Critical: qrc:/ChartJsTest.qml onLoadingChanged Could not connect to the server. Thu Apr 7 06:43:59 2022 1649328239365 Critical: qrc:/ChartJsTest.qml onLoadingChanged Could not connect to the server. Thu Apr 7 06:55:14 2022 1649328914809 Critical: qrc:/ChartJsTest.qml onLoadingChanged Could not connect to the server.

My suspiscions were probably right: is the QHttpServer that it's offline. I don't know why of course, but I guess a watchdog mechanism should trigger and fix the issue. What do you think?

rstrick9 commented 2 years ago

@cagnulein I think we're in business! The beta version worked great on consecutive rides!

Below are screenshots & debug from this consecutive session of 5 classes, some rides and some strength/stretch. Charts also pulled correctly as well!

My order of operations was as follows: -1. Start QZ -2. Start first class - hit Yes on prompt to follow auto-resist -3. Finish class & hit Stop, go to charts screen -4. Back out of chart screen (QZ was in the PAUSE state by default) -5. Start next workout, auto-follow prompt comes up, QZ still paused -6. Wait for intro countdown to reach desired time (6sec for me), hit yes on follow & hit start -7. Repeat steps 3+

image_7 IMG_3008 debug-Fri-Apr-8-05-53-10-2022.log

cagnulein commented 2 years ago

Great news! Share the good news on FB if you want!

rstrick9 commented 2 years ago

@cagnulein Will do!

When do you expect the 2.10 build to roll out to general users?

cagnulein commented 2 years ago

@rstrick9 i guess not before may. i did a lot of things in this series and i want to be sure that everything is ok

cagnulein commented 2 years ago

@rstrick9 i will send you a new beta in an hour. I added a new debug log (thanks @p3g4asus ) to understand the blank chart issue. Send me a debug log if it will happen again

rstrick9 commented 2 years ago

@cagnulein Any changes I need to check for, or any other items you're working on you'd like me to test for while I'm on the beta?

cagnulein commented 2 years ago

@rstrick9 no thanks, just test is as you did. let's see if the charts issue still happen (i didn't fix it, just add some debug log to understand it better)

rstrick9 commented 2 years ago

@cagnulein Hey Roberto, another successful session on the new build. Attaching a debug for today just in case there's anything else you're looking for on the other fixes.

Let me know if you need anything!

debug-Mon-Apr-11-05-43-07-2022.log

cagnulein commented 2 years ago

great @rstrick9 what about the charts?

rstrick9 commented 2 years ago

@cagnulein Charts have all been good, no issues there

cagnulein commented 2 years ago

ok thanks!

rstrick9 commented 2 years ago

@cagnulein Another good day of great functionality on the build, no issues with what was fixed.

I did see a post on the group you'd replied to, and I notice the same thing, so maybe I can assist with this as well.

Bike Model: Echelon EX3 On initial startup, QZ connects, quickly disconnects, and will reconnect ~20-30sec later. Once this is done, so long as QZ isn't closed there is no problem. If QZ is closed & reopened, the same thing happens again.

I've attached debug below and will send you the video via Messenger for reference, maybe this will help the people who state the same thing.

debug-Wed-Apr-13-05-52-12-2022.log

cagnulein commented 2 years ago

Hi @rstrick9 thanks for the log. It's really strange, it seems that sometimes the bike it doesn't want to send me its information and so QZ will go into timeout (30 seconds) and then, on the next attempt, it works. I don't think it's releated to the user on facebook, but it might be of course. I will keep this in mind. Thanks

P.S. Is it deterministic?

rstrick9 commented 2 years ago

Hey @cagnulein, I don't think it's a deterministic issue since this is something that's always happened as long as I've had the bike, every time it connects to QZ regardless of how long the bike has been turned on.

I think it other users are having the same issue from what I've read.

Also, today was another day of the charts not populating, so I've added the debug below. I'm certain this time that QZ was in the foreground this whole time. The only thing that happened near the beginning of the session near 5:45am was I received a text notification but didn't address or leave QZ to look at it.

Let me know your thoughts!

debug-Wed-Apr-13-07-01-45-2022.log

cagnulein commented 2 years ago

hah ok thanks @rstrick9 I have to double check this so. Also for the chart issue @p3g4asus , no "innerTcpServer is not LISTENING" debug log are available in this file, so maybe there is something else...I will study this case on vacation. Thanks for reporting this @rstrick9

rstrick9 commented 2 years ago

@cagnulein My pleasure!

Enjoy your vacation and all QZ problems can wait! :D

rstrick9 commented 2 years ago

Here's another debug from today's session where charts didn't populate. All the same as before, without receiving any notifications during the session.

Hope your vacation is going well!

debug-Tue-Apr-19-06-51-41-2022.log

cagnulein commented 2 years ago

thanks @rstrick9 ! Yes my vacation was really good but too short :D let me check the log, we have to fix this!