After receiving some reports from users, that they can't upload avatars because of error "Your avatar's file size is too large. Please upload an avatar no bigger than XX KB", I've tried to dig into the code.
It's a very strange idea to check user group avatar limits after uploading and resizing the source image. I'm talking about XenForo_Model_Avatar::applyAvatar() method. There is a condition at the line #146:
if ($maxFileSize != -1 && filesize($outputFiles[$sizeCode]) > $maxFileSize)
Here is an example. Let's say, that I have a PNG image about 6 KB. And avatar size limited to 9.8 KB. After uploading, the size of the resampled image is 34 KB. And now user sees the error message and the only thought that we can read in his eyes is "WTF!!! I've just uploaded the image of size 6 KB! "...
And here are variables from the debug process: