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

Can not view or use any Workouts or routines #722

Open
bejp0a opened this issue Jan 17, 2025 · 18 comments
Open

Can not view or use any Workouts or routines #722

bejp0a opened this issue Jan 17, 2025 · 18 comments

Comments

@bejp0a
Copy link

bejp0a commented Jan 17, 2025

Steps to Reproduce

My rule is that all new software that I have not fully figured out lives runs on either a yunohost machine or in a virtual machine. I have very, very limited experience with docker. The steps I follow to setup the local wger server are:

  1. spin up a virt machine with lxc and configure it so I can access it on the local network. The ip addresses are the ips of the virt machine host and of the virt machine which you can see with lxc list.
lxc launch ubuntu:22.04 v8 --vm
lxc config device override v8 eth0 ipv4.address=10.34.113.61
lxc config device add v8 myportv8z80 proxy listen=tcp:10.42.0.175:1785 connect=tcp:10.34.113.61:80 nat=true
lxc exec v8 bash
  1. go into virt machine and use docker (docker on virt machine bit weird but could not figure out how to setup bare metal)
su ubuntu
cd
sudo snap install docker
git clone https://github.com/wger-project/docker
cd docker
sudo docker compose up -d #need to do compuse up *before* editing .env file, which confused me a great deal
sudo docker compose down
echo '' >> ~/docker/config/prod.env #missed this step in orig post
echo 'CSRF_TRUSTED_ORIGINS=http://10.42.0.175:1785' >> ~/docker/config/prod.env
echo 'X_FORWARDED_PROTO_HEADER_SET=True' >> ~/docker/config/prod.env
sudo docker compose up -d

After following those steps I can go to http://10.42.0.175:1785 on any browser in my local network and have it "just work". Everything in the webui works fine as far as I can tell. But I anticpate using the web ui essentially never, I use my tablet for pretty much everything.

When I log into the android app or the flatpak app, I am unable to view any exhersizes. I cant start or record anything because there are no details. This is what the web ui looks like:

Image

And this is what the flutter app on desktop (and android, which is where I want to use but am using flatpak for convinence debugging) looks like:

Image

Image

Clicking on "add day" does let me add a day, but when I try to add an exhersize it just spins around forever, and wont let me add an exhersize

Image

If I launch the flatpak from the command line the error is:

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Bad state: No element
#0      ListBase.firstWhere (dart:collection/list.dart:132)
#1      new Exercise.fromApiData.<anonymous closure> (package:wger/models/exercises/exercise.dart:163)
#2      MappedListIterable.elementAt (dart:_internal/iterable.dart:425)
#3      ListIterator.moveNext (dart:_internal/iterable.dart:354)
#4      new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:189)
#5      new _GrowableList.of (dart:core-patch/growable_array.dart:150)
#6      new List.of (dart:core-patch/array_patch.dart:39)
#7      ListIterable.toList (dart:_internal/iterable.dart:224)
#8      new Exercise.fromApiData (package:wger/models/exercises/exercise.dart:165)
#9      new Exercise.fromApiDataJson (package:wger/models/exercises/exercise.dart:146)
#10     ExercisesProvider.handleUpdateExerciseFromApi (package:wger/providers/exercises.dart:340)
<asynchronous suspension>
#11     Future.wait.<anonymous closure> (dart:async/future.dart:534)
<asynchronous suspension>
#12     _SuggestionsSearchState.reload (package:flutter_typeahead/src/common/search/suggestions_search.dart:122)
<asynchronous suspension>

I noticed a bunch of other github issues with other folks mentioning they had issues loading exhersizes, wger-project/docker#108 (comment) but those look like issues with configurations, since for me everything works peachy keen in the web ui. The problem is with the flutter app someplace.

@rolandgeider
Copy link
Member

oh you got an exception! 😍 That will definitely help, when this happens to people using the app there's nothing to go on for. BTW, this is a fresh install after running sync-ingredients right?

@bejp0a
Copy link
Author

bejp0a commented Jan 17, 2025

its a fresh virtual machine each time I iterate the process but I dont uninstall and reinstall the flatpak, no. I do try purging the exhersize cache in the app bt that does not seem to do anything.

At various points I have tried running sudo docker compose exec web python3 manage.py sync-ingredients and 'sudo docker compose exec web python3 manage.py warmup-exercise-api-cache --force' and various other commands, but it does not seem to help.

@rolandgeider
Copy link
Member

weird, this has definitely something to do with the exercise data, but I can't explain where the problem comes from exactly. I also just tried a fresh install and could search without problems

Image

@bejp0a
Copy link
Author

bejp0a commented Jan 17, 2025

weird, this has definitely something to do with the exercise data, but I can't explain where the problem comes from exactly. I also just tried a fresh install and could search without problems

Image

Hm, well I got a similar error in android when looking up workouts as the flatpak:

date time pid E flutter : [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Bad state: No element
date time pid E flutter : #0      ListBase.firstWhere (dart:collection/list.dart:132)
date time pid E flutter : #1      new Exercise.fromApiData.<anonymous closure> (package:wger/models/exercises/exercise.dart:163)
date time pid E flutter : #2      MappedListIterable.elementAt (dart:_internal/iterable.dart:425)
date time pid E flutter : #3      ListIterator.moveNext (dart:_internal/iterable.dart:354)
date time pid E flutter : #4      new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:189)
date time pid E flutter : #5      new _GrowableList.of (dart:core-patch/growable_array.dart:150)
date time pid E flutter : #6      new List.of (dart:core-patch/array_patch.dart:39)
date time pid E flutter : #7      ListIterable.toList (dart:_internal/iterable.dart:224)
date time pid E flutter : #8      new Exercise.fromApiData (package:wger/models/exercises/exercise.dart:165)
date time pid E flutter : #9      new Exercise.fromApiDataJson (package:wger/models/exercises/exercise.dart:146)
date time pid E flutter : #10     ExercisesProvider.handleUpdateExerciseFromApi (package:wger/providers/exercises.dart:340)
date time pid E flutter : <asynchronous suspension>
date time pid E flutter : #11     Future.wait.<anonymous closure> (dart:async/future.dart:534)
date time pid E flutter : <asynchronous suspension>
date time pid E flutter : #12     _SuggestionsSearchState.reload (package:flutter_typeahead/src/common/search/suggestions_search.dart:122)
date time pid E flutter : <asynchronous suspension>
date time pid E flutter : 

idk what instance your app is connecting to, mine is connecting to http://10.42.0.175:1785 and using user admin adminadmin.

Are there other steps besides the ones I listed in my original post that must be performed? I have two instances running now and one did sudo docker compose exec web python3 manage.py sync-ingredients and the other did sudo docker compose exec web python3 manage.py warmup-exercise-api-cache --force and neither seem to work.

The logs server side show standard api calls that seem to wrok, and using curl to get exhersizes seems to work to. just not the app itself.

@rolandgeider
Copy link
Member

yes, making the url public is really helpful! Right now I can't access it, might be some network config? But no, sync-exercises is the only step you need to do (even the cache one is not necessary). I will try tomorrow again

@bejp0a
Copy link
Author

bejp0a commented Jan 19, 2025

I tried the app again this morning and now the app loads the exhersizes just fine. I am vey happy and very confused.

@Spatchy
Copy link

Spatchy commented Jan 20, 2025

I am experiencing the same issue on a fresh install. The annoying thing is, I can add exercises from the web UI just fine, but then the whole workout disappears from the mobile app. Is there maybe some data incompatibility between the web and app versions?

@rolandgeider
Copy link
Member

@Spatchy do you perhaps also have compiled the flutter app? Are you getting the same exception?

@bejp0a
Copy link
Author

bejp0a commented Jan 22, 2025

@Spatchy and @rolandgeider, If you are using the linux flatpak, you do not nessisarly need to compile the app yourself to get the error logs (something that I am personally almost never willing to do myself). If you dont have flatpak installed see here

if you have the app installed with flatpak you can type flatpak run de.wger.flutter in a terminal and it will open the UI like normal, and it will also print any debug logs that crop up. This is one of the reasons why I was so happy to see wger had a flatpak, even if I dont plan on using it all that much, since setting up adb to print android debug logs is huge pain.

@Spatchy
Copy link

Spatchy commented Jan 22, 2025

I can confirm I also get the same error when using the flatpak

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Bad state: No element
#0      ListBase.firstWhere (dart:collection/list.dart:132)
#1      new Exercise.fromApiData.<anonymous closure> (package:wger/models/exercises/exercise.dart:163)
#2      MappedListIterable.elementAt (dart:_internal/iterable.dart:425)
#3      ListIterator.moveNext (dart:_internal/iterable.dart:354)
#4      new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:189)
#5      new _GrowableList.of (dart:core-patch/growable_array.dart:150)
#6      new List.of (dart:core-patch/array_patch.dart:39)
#7      ListIterable.toList (dart:_internal/iterable.dart:224)
#8      new Exercise.fromApiData (package:wger/models/exercises/exercise.dart:165)
#9      new Exercise.fromApiDataJson (package:wger/models/exercises/exercise.dart:146)
#10     ExercisesProvider.handleUpdateExerciseFromApi (package:wger/providers/exercises.dart:340)
<asynchronous suspension>
#11     Future.wait.<anonymous closure> (dart:async/future.dart:534)
<asynchronous suspension>
#12     _SuggestionsSearchState.reload (package:flutter_typeahead/src/common/search/suggestions_search.dart:122)
<asynchronous suspension>

@bejp0a
Copy link
Author

bejp0a commented Jan 22, 2025

@Spatchy did you download images for your workouts? I think the fact that I did not do that on one of my servers is what lets that one work. Even if thats not it, there is probable some tweak you can perform to get the app to a usable state.

While there maybe some server tweaks that will fix this issue for users, I still fundamentally think this is an issue with the flutter app, it should be able to handle some small misconfig issues the same way the web client does.

The reason I think its images is because I currently have to virtual machines, one with wger working for the flutter app, and one where it is not wo0rking with the flutter app. If I do an api request with curl -X 'GET' 'http://10.42.0.175:1785/api/v2/exercise/search/?language=en&term=Hip' -H 'accept: application/json' to the working server, no image data is returned. When I do the same request to the broken server , it looks nearly exactly the same, but one of the results has an image link.

api result from working server:

{"suggestions":[{"value":"Hip Thrust","data":{"id":854,"base_id":294,"name":"Hip Thrust","category":"Legs","image":null,"image_thumbnail":null}},{"value":"Hip Raise, Lying","data":{"id":376,"base_id":292,"name":"Hip Raise, Lying","category":"Back","image":null,"image_thumbnail":null}},{"value":"Barbell Hip Thrust","data":{"id":1156,"base_id":901,"name":"Barbell Hip Thrust","category":"Legs","image":null,"image_thumbnail":null}},{"value":"Barbell Hip Thrust","data":{"id":1157,"base_id":902,"name":"Barbell Hip Thrust","category":"Legs","image":null,"image_thumbnail":null}},{"value":"Barbell Hip Thrust","data":{"id":1161,"base_id":906,"name":"Barbell Hip Thrust","category":"Legs","image":null,"image_thumbnail":null}},{"value":"Seated Hip Adduction","data":{"id":377,"base_id":12,"name":"Seated Hip Adduction","category":"Legs","image":null,"image_thumbnail":null}},{"value":"Hand Grip","data":{"id":317,"base_id":279,"name":"Hand Grip","category":"Arms","image":null,"image_thumbnail":null}},{"value":"High Pull","data":{"id":164,"base_id":289,"name":"High Pull","category":"Shoulders","image":null,"image_thumbnail":null}},{"value":"High Pull","data":{"id":2143,"base_id":1187,"name":"High Pull","category":"Back","image":null,"image_thumbnail":null}},{"value":"Side Lying Hip Abduction","data":{"id":2161,"base_id":1202,"name":"Side Lying Hip Abduction","category":"Legs","image":null,"image_thumbnail":null}},{"value":"High knees","data":{"id":1529,"base_id":983,"name":"High knees","category":"Cardio","image":null,"image_thumbnail":null}},{"value":"High plank","data":{"id":1779,"base_id":1001,"name":"High plank","category":"Chest","image":null,"image_thumbnail":null}},{"value":"Good Morning","data":{"id":2358,"base_id":1348,"name":"Good Morning","category":"Legs","image":null,"image_thumbnail":null}}]}

api result from broken (it works on web but not flatpak / mobile):

{"suggestions":[{"value":"Hip Thrust","data":{"id":854,"base_id":294,"name":"Hip Thrust","category":"Legs","image":null,"image_thumbnail":null}},{"value":"Hip Raise, Lying","data":{"id":376,"base_id":292,"name":"Hip Raise, Lying","category":"Back","image":null,"image_thumbnail":null}},{"value":"Barbell Hip Thrust","data":{"id":1156,"base_id":901,"name":"Barbell Hip Thrust","category":"Legs","image":null,"image_thumbnail":null}},{"value":"Barbell Hip Thrust","data":{"id":1157,"base_id":902,"name":"Barbell Hip Thrust","category":"Legs","image":null,"image_thumbnail":null}},{"value":"Barbell Hip Thrust","data":{"id":1161,"base_id":906,"name":"Barbell Hip Thrust","category":"Legs","image":null,"image_thumbnail":null}},{"value":"Seated Hip Adduction","data":{"id":377,"base_id":12,"name":"Seated Hip Adduction","category":"Legs","image":null,"image_thumbnail":null}},{"value":"Hand Grip","data":{"id":317,"base_id":279,"name":"Hand Grip","category":"Arms","image":null,"image_thumbnail":null}},{"value":"High Pull","data":{"id":164,"base_id":289,"name":"High Pull","category":"Shoulders","image":null,"image_thumbnail":null}},{"value":"High Pull","data":{"id":2143,"base_id":1187,"name":"High Pull","category":"Back","image":"/media/exercise-images/1187/cd16b706-b9d2-47a7-81cf-a27724017d89.jpg","image_thumbnail":"/media/exercise-images/1187/cd16b706-b9d2-47a7-81cf-a27724017d89.jpg.30x30_q85_crop-smart.jpg"}},{"value":"Side Lying Hip Abduction","data":{"id":2161,"base_id":1202,"name":"Side Lying Hip Abduction","category":"Legs","image":null,"image_thumbnail":null}},{"value":"High knees","data":{"id":1529,"base_id":983,"name":"High knees","category":"Cardio","image":null,"image_thumbnail":null}},{"value":"High plank","data":{"id":1779,"base_id":1001,"name":"High plank","category":"Chest","image":null,"image_thumbnail":null}},{"value":"Good Morning","data":{"id":2358,"base_id":1348,"name":"Good Morning","category":"Legs","image":null,"image_thumbnail":null}}]}

@rolandgeider
Copy link
Member

Besides the fact that I can't for the life of me reproduce this, the error in the exception relates to exercise translations, not images. In any case, I've added a workaround there and will push a new version later today

rolandgeider added a commit that referenced this issue Jan 22, 2025
@rolandgeider
Copy link
Member

have just pushed a new flatpak package, should be available on flathub in a couple of hours

@Spatchy
Copy link

Spatchy commented Jan 24, 2025

@rolandgeider Thanks for this, although there seems to be an issue with the language settings when searching for exercises now. I'm not sure if this is a result of your workaround or something completely unrelated. If I go to the web interface and add, for example "Bench Press" It will show up there as expected, but if I now view it in the Flatpak, it shows in German:

Image

Let me know if I should open a separate issue for this

@rolandgeider
Copy link
Member

no, it's the same issue, the actual problem was that for some reason the languages could not be found/mapped. If you go to /api/v2/language/, how many entries do you have in count?

@bejp0a
Copy link
Author

bejp0a commented Jan 24, 2025

no, it's the same issue, the actual problem was that for some reason the languages could not be found/mapped. If you go to /api/v2/language/, how many entries do you have in count?

I am experiencing the same issue on a new VM I spun up with the exact same steps in the original issue. I suspect its because I never changed the time zone in the config from german to US, but issue persists even after changing the config in that same vm. no errors in flutter terminal that I can see.

have not yet tested changing the time zone in a fresh vm.

as for api, I get 24 entries in the count.

Full output from command:

curl -X 'GET' 'http://10.42.0.175:1785/api/v2/language/' -H 'accept: application/json'

{"count":24,"next":"http://10.42.0.175/api/v2/language/?limit=20&offset=20","previous":null,"results":[{"id":18,"short_name":"az","full_name":"Azərbaycan dili","full_name_en":"Azerbaijani"},{"id":23,"short_name":"id","full_name":"Bahasa Indonesia","full_name_en":"Indonesian"},{"id":1,"short_name":"de","full_name":"Deutsch","full_name_en":"German"},{"id":2,"short_name":"en","full_name":"English","full_name_en":"English"},{"id":4,"short_name":"es","full_name":"Español","full_name_en":"Spanish"},{"id":19,"short_name":"eo","full_name":"Esperanto","full_name_en":"Esperanto"},{"id":12,"short_name":"fr","full_name":"Français","full_name_en":"French"},{"id":22,"short_name":"hr","full_name":"Hrvatski jezik","full_name_en":"Croatian"},{"id":13,"short_name":"it","full_name":"Italian","full_name_en":"Italian"},{"id":6,"short_name":"nl","full_name":"Nederlands","full_name_en":"Dutch"},{"id":11,"short_name":"no","full_name":"Norsk","full_name_en":"Norwegian"},{"id":14,"short_name":"pl","full_name":"Polish","full_name_en":"Polish"},{"id":7,"short_name":"pt","full_name":"Português","full_name_en":"Portuguese"},{"id":10,"short_name":"sv","full_name":"Svenska","full_name_en":"Swedish"},{"id":16,"short_name":"tr","full_name":"Türkçe","full_name_en":"Turkish"},{"id":9,"short_name":"cs","full_name":"Čeština","full_name_en":"Czech"},{"id":8,"short_name":"el","full_name":"Ελληνικά","full_name_en":"Greek"},{"id":3,"short_name":"bg","full_name":"Български език","full_name_en":"Bulgarian"},{"id":5,"short_name":"ru","full_name":"Русский","full_name_en":"Russian"},{"id":15,"short_name":"uk","full_name":"Українська мова","full_name_en":"Ukrainian"}]}

Thanks a bunch for setting up /api/v2/schema/ui by the way. really helped with setting up some simple bash scripts to do automatic data entry for sleep tracking. The whole generic measurments thing is awesome

Also, I am unable to reproduce this issue on a public facing VPS. The differences are its a debian 12 vps, it does not run in a virtual machine and so does not have the

echo '' >> ~/docker/config/prod.env #missed this step in orig post
echo 'CSRF_TRUSTED_ORIGINS=http://10.42.0.175:1785' >> ~/docker/config/prod.env
echo 'X_FORWARDED_PROTO_HEADER_SET=True' >> ~/docker/config/prod.env

parts, and things seem to work hunky dory. If I can reproduce the issue on a public IP I'll share it, but I am not sure if I can spin up lxc in a vps

@Spatchy
Copy link

Spatchy commented Jan 24, 2025

I also have 24 in count. My TIME_ZONE environment variable is set to Europe/London and has been that way since I spun up the container for the first time.

@rolandgeider
Copy link
Member

yeah, 24 is the right number 😄

The time zone shouldn't have any effect, in the flutter app we always download all available languages. I would understand if you had added a new one on the server as well as some exercise translations for it. And like I said, I've never managed to reproduce this with fresh docker compose setups, fresh android emulators, etc. I'll add some log messages to see if we can narrow this down

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

3 participants