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

Avatar Generation does not work of single letter users #1628

Closed
1 task
szaimen opened this issue Dec 29, 2022 · 40 comments
Closed
1 task

Avatar Generation does not work of single letter users #1628

szaimen opened this issue Dec 29, 2022 · 40 comments
Labels
1. to develop Accepted and waiting to be taken care of bug Something isn't working help wanted Extra attention is needed high High priority

Comments

@szaimen
Copy link
Collaborator

szaimen commented Dec 29, 2022

Already tried a lot of things but nothing did make it work:

@szaimen szaimen added 0. Needs triage Pending approval or rejection. This issue is pending approval. bug Something isn't working labels Dec 29, 2022
@szaimen szaimen changed the title Avatar Generation does not work. Maybe need imagemagick6? Avatar Generation does not work of single letter users Dec 29, 2022
@szaimen szaimen added the help wanted Extra attention is needed label Dec 29, 2022
@szaimen
Copy link
Collaborator Author

szaimen commented Jan 10, 2023

Maybe it has to do with imagemagicks policy.xml but I tried to modify that and it still didnt work so out of ideas again...

@szaimen szaimen added 1. to develop Accepted and waiting to be taken care of high High priority and removed 0. Needs triage Pending approval or rejection. This issue is pending approval. labels Jan 16, 2023
@ManOki
Copy link
Collaborator

ManOki commented Jan 17, 2023

does not work even with long user names

avatars

@szaimen
Copy link
Collaborator Author

szaimen commented Jan 17, 2023

Interesting! So yeah, I tried my best but didn't find a solution. Help on this is appreciated! My last thought was that it might be the policy.xml from imaginary but even adjusting that didn't made it work...

@Zoey2936
Copy link
Collaborator

Does this error only exist under some conditions? Since on my AIO Instance it is working... (v4.2.0)
grafik

@szaimen
Copy link
Collaborator Author

szaimen commented Jan 17, 2023

Does this error only exist under some conditions? Since on my AIO Instance it is working... (v4.2.0)
grafik

do you have imagick installed and enabled?

@Zoey2936
Copy link
Collaborator

Does this error only exist under some conditions? Since on my AIO Instance it is working... (v4.2.0)
grafik

do you have imagick installed and enabled?

grafik
I would say yes and in my config.php is set:

  'enabledPreviewProviders' => 
  array (
    1 => 'OC\\Preview\\Image',
    2 => 'OC\\Preview\\MarkDown',
    3 => 'OC\\Preview\\MP3',
    4 => 'OC\\Preview\\TXT',
    5 => 'OC\\Preview\\OpenDocument',
    6 => 'OC\\Preview\\Movie',
    0 => 'OC\\Preview\\Imaginary',
  ),
  'enable_previews' => true,
  'preview_imaginary_url' => 'http://nextcloud-aio-imaginary:9000',

@szaimen
Copy link
Collaborator Author

szaimen commented Jan 17, 2023

do you have imagick installed and enabled?

You can check it here: https://yourdomain.com/settings/admin/overview. If it is not enabled it should show a warning.

@Zoey2936
Copy link
Collaborator

grafik

@szaimen
Copy link
Collaborator Author

szaimen commented Jan 17, 2023

grafik

hm, okay then no idea why it works for you. Maybe some difference between arm64 and amd64? But yeah, really no clue.

@szaimen
Copy link
Collaborator Author

szaimen commented Jan 17, 2023

btw, one workaround that I've found is disabling imagemagick but this will show a warning in the admin overview so is really only a workaround.

@EgonHeuson
Copy link

Hello! I did some quick behavior tests and here are the results (on my amd64 config).
When I add an avatar to a user, its avatar is generated correctly, and it can see the avatars of the users that added avatars to themselves before him somehow.
I noticed I had this problem too this evening, then to test I added a Dog avatar to a test account just to see if it was only coming from the letters avatar or from all. Strangely it seems to propagate as it can be seen below.
Here is what I see if I connect to my account:
2023-01-24_23-40-37
Then I tested the same with the admin account to check, and I get this when I'm connected with this account:
2023-01-24_23-44-13
So it seems to see all the avatars. But when I come back to my account, I still cannot see the one of my admin account:
2023-01-24_23-45-41
Same for a 4th account I tested, but this time it can see its own avatar, but not the one of my account like the Admin account.
I don't know if this might help you or not? I can do some more testing if you like :-)

@EgonHeuson
Copy link

Samll update on this :-) This morning, I just reconnected to my nextcloud account and now I can see the avatar of my admin account :-) However, it is not the good one showing 😅. Here is what I get from my user account:
2023-01-25_10-07-07
And here is what I get from my admin account (when I go to "users"):
2023-01-25_10-09-49
The second image is the actual one. The first one is one image I first uploaded yesterday evening to see it it worked, and then I uploaded the second one. Strange no?
Also, I asked a friend of mine who has an account to add a picture. And 1) it could yesterday see all of the ones that where already uploaded to my user accounts and my admin account, and 2) I now can see his avatar while I could not see it yesterday evening just after it uploaded it.
I have to precise that I execute this command every night at 3am via a Cron job: docker exec --user www-data nextcloud-aio-nextcloud /var/www/html/occ files:scan --all
It is to update the files that I may have manually added in my Nextcloud folder on my NAS. But maybe it refreshes something else?
One last thought, I feel like when somebody adds up a new avatar, the people who does it sees the ones of the people that already uploaded their avatar before him, but not those who did it after. And more that it might get reseted on specific action/command/event, or maybe it just take some time to propagate to the other users?
You didn't propose a mastercontainer update the last night, right?

@szaimen
Copy link
Collaborator Author

szaimen commented Jan 25, 2023

Thanks for your posts @EgonHeuson! However the more I think about your findings, the more I think that this is a different bug than the one that this issue is about. The bug which this issue is about is only about the default avatars not getting generated correctly.

@EgonHeuson
Copy link

Argh damned! 😅 I also have the issue with default avatars generation but hard to distinguish if it is link to the other issue in my case or not... 😥

@VitaleyUsa
Copy link

Sorry for the long reply.
Just did a quick test with profile avatars when i'm not logged in: i can see generated avatar picture (but with one letter instead of two)
for example: when i'm already logged in, only background shown with no letters
when i'm logged out and just checking profile link of the same user: i can see letter on profile pic:
image

or maybe i not properly cleaned avatar cache?

@szaimen
Copy link
Collaborator Author

szaimen commented Jan 28, 2023

or maybe i not properly cleaned avatar cache?

Can you clear the browser cache ans check if it still works?

@VitaleyUsa
Copy link

or maybe i not properly cleaned avatar cache?

Can you clear the browser cache ans check if it still works?

it works, i'm testing in incognito to remove cache factor :)

@szaimen
Copy link
Collaborator Author

szaimen commented Jan 28, 2023

All right. Just tried on my test instance and avatar generation of single name users does not work even in incognito tab. Are you on arm64?

@VitaleyUsa
Copy link

VitaleyUsa commented Jan 28, 2023

All right. Just tried on my test instance and avatar generation of single name users does not work even in incognito tab. Are you on arm64?

Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 40 bits physical, 48 bits virtual Byte Order: Little Endian CPU(s): 2 On-line CPU(s) list: 0,1 Vendor ID: AuthenticAMD Model name: Common KVM processor CPU family: 15 Model: 6 Thread(s) per core: 1 Core(s) per socket: 2 Socket(s): 1 Stepping: 1 BogoMIPS: 4599.99 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm rep_good nopl cpuid extd_apicid tsc_known_freq pni cx16 x2apic hypervisor cmp_legacy 3dnowprefetch vmmcall Virtualization features: Hypervisor vendor: KVM Virtualization type: full Caches (sum of all): L1d: 128 KiB (2 instances) L1i: 128 KiB (2 instances) L2: 1 MiB (2 instances) L3: 32 MiB (2 instances) NUMA: NUMA node(s): 1 NUMA node0 CPU(s): 0,1 Vulnerabilities: Itlb multihit: Not affected L1tf: Not affected Mds: Not affected Meltdown: Not affected Mmio stale data: Not affected Retbleed: Not affected Spec store bypass: Not affected Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Spectre v2: Mitigation; Retpolines, STIBP disabled, RSB filling Srbds: Not affected Tsx async abort: Not affected

i'm noticed that in incognito mode i have dif. language:
image

when i'm logged in:
image

@szaimen
Copy link
Collaborator Author

szaimen commented Jan 28, 2023

So it seems to work for you correctly on x64. Now I am even more clueless...

@VitaleyUsa
Copy link

So it seems to work for you correctly on x64. Now I am even more clueless...

no! sorry, deleted my upd: it's what i have when i'm using ur hack from another thread

@VitaleyUsa
Copy link

Sorry for misunderstand.
I did last screen (with ur fix from another thread) only to show u that i have dif. language.
But when i have no fix enabled, it shows letters only when i'm not logged in.

@szaimen
Copy link
Collaborator Author

szaimen commented Jan 28, 2023

But when i have no fix enabled, it shows letters only when i'm not logged in.

Which fix? you mean disabling imagemagick?

@VitaleyUsa
Copy link

But when i have no fix enabled, it shows letters only when i'm not logged in.

Which fix? you mean disabling imagemagick?

nextcloud/server#34755 (comment)

@szaimen
Copy link
Collaborator Author

szaimen commented Jan 28, 2023

This comment is not made by me.

@VitaleyUsa
Copy link

Ooooooh, all this time i thought it was yours :(
sorry!

@szaimen
Copy link
Collaborator Author

szaimen commented Jan 28, 2023

All good!

@VitaleyUsa
Copy link

VitaleyUsa commented Jan 29, 2023

Just did another test with no fix:

  1. That's what i have when i'm logged in:
    image

  2. That's what i have when i'm not logged in (no cache):
    image

Also, i decide to check what happening when i'm cleaning avatar folder:

  1. When i'm logged in:
    image

  2. When i'm not logged in:
    image

Seems like, when i'm not logged in profile pictures are generating in some other place (not in data/appdata_xxxxx/avatar):
image

So.. when you not logged in, nextcloud uses different way to show profile picture, it's not generated then. I checked source code of the page (changed name to "Test"):
image

the result:
image

probably, no point to search in this way, cuz it has dif. way of profile pic. generation (also no correlation with language, i tried Ru lang, it still works when i'm not logged in)

@VitaleyUsa
Copy link

VitaleyUsa commented Jan 29, 2023

@szaimen

i'm not a real programmer and my english is far from perfect, so ...

https://github.com/nextcloud/server/blob/v25.0.0/lib/private/Avatar/Avatar.php#L142

is it right that this line looks like this: catch (\Exception $e)
because if i changing it to: catch (Exception $e)
(removing backslash symbol before Exception)
it's starts to work as expected.
as i can see it's something with using global namespaces (and catching all exceptions instead of local?) but i can't understand why it ruins avatar generation anyway.
is it because some exception appears, and function returns null because of it?

so, in summary:

  1. remove avatar cache from nc folder and from browser
  2. remove backslash symbol in Avatar.php in 142 line "catch (Exception $e)" (use local exception instead of global) or remove try cache block
  3. generate avatars by php occ files:scan-app-data avatar
  4. it is generating avatars now

Did some tests and find out that profile pics are generating in every place (on main dashboard, in list of users) except when you come to user profile, so prob. that's the main problem, exception just won't allow script to generate everything else.
I mean... when we have exception enabled - it starts to generate profile pic for user profile, something happening (exception appears) and function return null and not trying to generate profile pics that are shown on main board and in the list of users.

i dunno how to show exception by changing Avatar.php, tried this:
echo 'Message: ' .$e->getMessage();
but it's not working
so can't say anything more about this :]

ps what function are responsible for profile pic generation when u go direct to user profile?

@szaimen
Copy link
Collaborator Author

szaimen commented Jan 30, 2023

Sorry, I have also already played with this a lot and no changes in catching the exception make any difference on my test instance. So it should work since no error is thrown but it doesnt generate the avatar. As you, I am out of ideas but thanks for your attempt!

@VitaleyUsa
Copy link

VitaleyUsa commented Jan 30, 2023

Sorry, I have also already played with this a lot and no changes in catching the exception make any difference on my test instance. So it should work since no error is thrown but it doesnt generate the avatar. As you, I am out of ideas but thanks for your attempt!

I might be wrong, but it seems like the problem here = svg format.
Try to add this code:

$avatar->setFormat('SVG');

before this line: https://github.com/nextcloud/server/blob/v25.0.0/lib/private/Avatar/Avatar.php#L137

In result it should be like this:

> protected function generateAvatarFromSvg(int $size, bool $darkTheme): ?string {
>                 if (!extension_loaded('imagick')) {
>                         return null;
>                 }
>                 try {
>                         $font = __DIR__ . '/../../../core/fonts/NotoSans-Regular.ttf';
>                         $svg = $this->getAvatarVector($size, $darkTheme);
>                         $avatar = new Imagick();
>                         $avatar->setFont($font);
>                         $avatar->setFormat('SVG');
>                         $avatar->readImageBlob($svg);
>                         $avatar->setImageFormat('png');
>                         $image = new \OCP\Image();
>                         $image->loadFromData((string)$avatar);
>                         return $image->data();
>                 } catch (\Exception $e) {
>                         return null;
>                 }
>         }
> 

Now everything is fine. Avatars are generating in every place as it should be.

Am i wrong?

ps strange thing here: svg template already have this:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
but it's not working, maybe something is changing svg template and first line is corrupted?

@szaimen
Copy link
Collaborator Author

szaimen commented Feb 8, 2023

Cross-linking nextcloud/server#36607 here. However I hope that we'll find a solution to this sooner.

@spss20
Copy link

spss20 commented Mar 17, 2023

I've been following this issue for a long time. Why is there no solution yet for a simple thing? It's been months.

@szaimen
Copy link
Collaborator Author

szaimen commented Mar 17, 2023

Why is there no solution yet for a simple thing? It's been months.

Because we didnt found a solution yet. See our investigations and attempts above.

If the solution would be easy, we would have fixed the problem a long time ago.

If you have further ideas on a technical solution, feel free to post them here.

@spss20
Copy link

spss20 commented Mar 17, 2023

@szaimen Thanks for updating. However i would like to bring the fact that there is no such issue in the docker standalone version of nextcloud. The problem exists only in all-in-one installation of nextcloud. Just curious.

@szaimen
Copy link
Collaborator Author

szaimen commented Mar 17, 2023

However i would like to bring the fact that there is no such issue in the docker standalone version of nextcloud.

did you use the fpm-alpine image or the apache version?

@Jip-Hop
Copy link

Jip-Hop commented Mar 17, 2023

I have the same issue on a linuxserver.io nextcloud image so the issue isn't exclusive to aio. Both are based on alpine though.

@szaimen
Copy link
Collaborator Author

szaimen commented Mar 17, 2023

I have the same issue on a linuxserver.io nextcloud image so the issue isn't exclusive to aio. Both are based on alpine though.

Yes, this is my observation as well.

@szaimen
Copy link
Collaborator Author

szaimen commented Mar 29, 2023

@szaimen
Copy link
Collaborator Author

szaimen commented Mar 30, 2023

nextcloud/server#37378

@szaimen szaimen closed this as completed Mar 30, 2023
szaimen added a commit that referenced this issue Apr 1, 2023
after #1628 was fixed
Signed-off-by: Simon L <szaimen@e.mail.de>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1. to develop Accepted and waiting to be taken care of bug Something isn't working help wanted Extra attention is needed high High priority
Projects
None yet
Development

No branches or pull requests

7 participants