News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Avatars sometimes load then disappear

Started by jamescormack, August 24, 2009, 10:16:32 AM

Previous topic - Next topic

Norv

sublimeCAT: that may be because of errors on the page. (javascript errors). Perhaps checking the error console ("Tools" menu in browsers like Opera and Firefox) would help identifying them.
To-do lists are for deferral. The more things you write down the later they're done... until you have 100s of lists of things you don't do.

File a security report | Developers' Blog | Bug Tracker


Also known as Norv on D* | Norv N. on G+ | Norv on Github

rgecy

What is the latest on this issue?  I am having users say they can't upload avatars, or they show up as a blank box with an x, or they appear sometimes, and then disappear.

I have also noticed that the "My Images" in the Ultimate Profile is doing this.  If you go to upload an image, it will either not show or show with an x.

I have not had any issues as admin getting mine to upload, but logged in as regular member and had issues.  Aslo had issues logged in as admin and went into another users account to upload avatar and problem occurred.

I am running 2.0RC1.2 with a modified default theme.

What can I do to help diagnose this problem?

Thanks,

RGecy

rgecy

Any help with this?  I am starting to see more and more users avatars not loading.

I noticed this error in the log.

Database Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '}profile_pictures
WHERE id_member IN (723)' at line 2
File: /home/content/r/g/e/rgecy1/html/forums/Sources/Subs-Members.php
Line: 386 


Here is the code:
Quote366:       DELETE FROM {db_prefix}profile_comments
367:       WHERE comment_member_id IN ({array_int:users})',
368:       array(
369:          'users' => $users,
370:       )
371:    );
372:    $smcFunc['db_query']('', '
373:       DELETE FROM {db_prefix}profile_albums
374:       WHERE id_member IN ({array_int:users})',
375:       array(
376:          'users' => $users,
377:       )
378:    );
379:    $smcFunc['db_query']('', '
380:       SELECT id_picture
381:       FROM {$db_prefix}profile_pictures
382:       WHERE id_member IN ({array_int:users})',
383:       array(
384:          'users' => $users,
385:       )
==>386:    );
387:    
388:    require_once($sourcedir . '/Profile-Pictures.php');
389:    while ($row = $smcFunc['db_fetch_assoc']($request)) {
390:       delete_picture($row['ID_PICTURE']);
391:    }
392: 
393:    // Make their votes appear as guest votes - at least it keeps the totals right.
394:    //!!! Consider adding back in cookie protection.

Thanks,

RGecy

Norv

rgency can you please tell if it happens with the workaround indicated above:
Quote from: sublimeCAT on September 24, 2009, 11:42:41 AM
I just noticed that this only happens when in the avatars settings for external avatars the option "resize it with javascript" is activated.

Right now i chose the setting "let the HTML resize it" and it's fine, but it seems it's an itsy bitsy slower to load the pages.

Also, can you please run the tool provided at http://www.simplemachines.org/community/index.php?topic=313201.0 just to be sure?

Please consider telling a link to your forum, as well, with a test account (normal user account), perhaps we can take a look and notice something of relevance.
To-do lists are for deferral. The more things you write down the later they're done... until you have 100s of lists of things you don't do.

File a security report | Developers' Blog | Bug Tracker


Also known as Norv on D* | Norv N. on G+ | Norv on Github

Arantor

Edit line 381.

It should not read:
FROM {$db_prefix}profile_pictures

But must be:
FROM {db_prefix}profile_pictures

rgecy

OK, I edited line 381.  Got rid of the error in log, but I still cannot get the avatars to display correctly.  The resize has no affect on my issue.

Here is one that keeps giving me problems.  I went into the users Profile and uploaded his avatar.  When I click Change Profile it refreshed and did not show his avatar and would not show in his profile on post.

Then, I went to Profile Summary, which is Ultimate Profle, and the avatar showed up.  Then I went back to Forum Profile and it was there.  And it is showing in profile under post.  ??? ??? ???

Robert

Norv

Missing the picture first time only, I wonder if it might be because of the browser cache, or simply having a difficulty loading it for the moment...
Can you have it happen again, is there some sort of pattern, though?
To-do lists are for deferral. The more things you write down the later they're done... until you have 100s of lists of things you don't do.

File a security report | Developers' Blog | Bug Tracker


Also known as Norv on D* | Norv N. on G+ | Norv on Github

AtlantaSteve

One of my users is experiencing this very issue.  His avatar disappears after first loading.  It only happens with this user who has his avatar hosted offsite, with a size that is larger than the max sizes we have defined, and it happens during javascript Resizing.

So, I debugged and discovered the lines of code where this is happening.

in script.js, in the function smf_avatarResize:


var tempAvatar = new Image();
tempAvatar.src = possibleAvatars[i].src;

if (smf_avatarMaxWidth != 0 && tempAvatar.width > smf_avatarMaxWidth)
{
  possibleAvatars[i].height = (smf_avatarMaxWidth * tempAvatar.height) / tempAvatar.width;
  possibleAvatars[i].width = smf_avatarMaxWidth;
}
else if (smf_avatarMaxHeight != 0 && tempAvatar.height > smf_avatarMaxHeight)
{
  possibleAvatars[i].width = (smf_avatarMaxHeight * tempAvatar.width) / tempAvatar.height;
  possibleAvatars[i].height = smf_avatarMaxHeight;
}
else
{
  possibleAvatars[i].width = tempAvatar.width;
  possibleAvatars[i].height = tempAvatar.height;
}


When I stepped through the code, everything worked perfectly.  The debugger stepped into the first if block (as it should have) resized his image correctly, and Bob's your uncle.

But when I removed all breakpoints and reran it, again his avatar disappeared.

So I placed a breakpoint on the first line of each of the if/else blocks and found that when it ran without pausing, it was dropping into the last block (Where it just reassigns height/width from tempAvatar), but that the height and width were the actual image's size.  So again, the image didn't disappear.  Weird.

Then I removed all breakpoints, and set a new one at the END of the last else block.  And when I did that?  It broke.

So I dug and figured out what's going on here.

The second line in my code block above (where tempAvatar.src is set) tells the browser to load the image into this in-memory Image object, and then tries to get the width and height values.  However, the javascript engine is not stopping to wait for the image to load, and for those values to be filled correctly.  When I debug, since the engine is running one line at a time, the "halt" gives the loader time to finish loading the image, and correctly fill out those values, but as long as the engine is unencumbered by the debugger, it doesn't fill those values, so height and width on tempAvatar still have their default values of 0,0

This was verified by adding console.log() statements showing me the height and width.  If I placed an alert('hi') right after tempAvatar.src is set, then the alert's blocking gave the image loader time to catch up, and again the code worked correctly.

It is my opinion this code is buggy on Firefox, (only tested this on Firefox with FireBug to this point) and that there needs to be some sort of wait or delay after the tempAvatar.src has been set.

In the meantime, I suppose we can switch to HTML Resizing, but I wanted to make you aware of what the issue is.  If you wish to see the actual issue in action, let me know and I'll send you a URL that demonstrates the buggy behavior.

I am using FireFox 3.5.3, don't know what my users are using, but they have reported seeing the issue as well.

Thanks,

Steven
Moderator: hxxp:stangfix.com [nonactive]

Norv

Steven,
Thank you very much for the time taken to debug the issue! I've tracked the issue thanks to your comments for the developers to look into it:
http://dev.simplemachines.org/mantis/view.php?id=3842
To-do lists are for deferral. The more things you write down the later they're done... until you have 100s of lists of things you don't do.

File a security report | Developers' Blog | Bug Tracker


Also known as Norv on D* | Norv N. on G+ | Norv on Github

AtlantaSteve

Good deal, thanks Norv!

I should add that it only seemed to happen with a user who had his image hosted on tripod.  Several use external hosting with photobucket and all is well with them, but the angelfire guy?  No good.  I suppose tripod is just slower?  Not sure.

Joshua Dickerson

What if after tempAvatar = new Image(); You did tempAvatar.width = smf_avatarMaxWidth; tempAvatar.height = smf_avatarMaxHeight; Then it will create an image that size and resize it later.
Come work with me at Promenade Group



Need help? See the wiki. Want to help SMF? See the wiki!

Did you know you can help develop SMF? See us on Github.

How have you bettered the world today?


Advertisement: