Mirror icon indicating copy to clipboard operation
Mirror copied to clipboard

OnDeserialize failed Exception=System.IO.EndOfStreamException

Open Stolichnayer opened this issue 3 years ago • 1 comments

Bug: OnDeserialize failed Exception=System.IO.EndOfStreamException (see below) object=PlayerPrefab(Clone) component=Mirror.NetworkAnimator sceneId=0 length=20

Reproduce: I'm building a FPS game where there is the main player's PlayerPrefab with two children like this: PlayerPrefab where:

  • FirstPersonCharacter: FPS camera + Firearms that only local player can see
  • Avatar : Full body avatar that all other players can see, except local player

NetworkTransform works great, all movement is being synchronized perfectly.

The exception is thrown when I add a NetworkAnimator component on PlayerPrefab and attach its child's Avatar Animator on the animator field.

The exception is not thrown when the Animator is on the same GameObject with the NetworkAnimator, for example both in the parent PlayerPrefab (as I can see it was fixed in #570 issue).

Screenshots PlayerPrefab PlayerPrefab

PlayerPrefab

I also recorded a video of the bug to make clearer what I'm trying to do.

https://www.youtube.com/watch?v=Y7p6N_PyiKM

Desktop:

  • OS: [Windows]
  • Build target: [Desktop]
  • Unity version: [2020.3.13f1]
  • Mirror Version: [42.2.12 - July 12, 2021 from AssetStore]

Stolichnayer avatar Jul 27 '21 13:07 Stolichnayer

Yup, same problem here.

robtherobot12 avatar Feb 11 '22 13:02 robtherobot12

sorry, late reply. sounds like NetworkAnimator isn't always serializing the same amount of data.

just to be clear @robtherobot12 @Stolichnayer are you changing NetworkAnimator's .animator field at runtime, or no?

miwarnec avatar Jan 29 '23 04:01 miwarnec

This was a while ago, but no, I wasn’t touching that property.

On Sun, 29 Jan 2023 at 04:17, mischa @.***> wrote:

sorry, late reply. sounds like NetworkAnimator isn't always serializing the same amount of data.

just to be clear @robtherobot12 https://github.com/robtherobot12 @Stolichnayer https://github.com/Stolichnayer are you changing NetworkAnimator's .animator field at runtime, or no?

— Reply to this email directly, view it on GitHub https://github.com/MirrorNetworking/Mirror/issues/2852#issuecomment-1407557439, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHY4D6DKROCP5NVBR2EDZLDWUXVNJANCNFSM5BCGTP4A . You are receiving this because you were mentioned.Message ID: @.***>

robtherobot12 avatar Jan 29 '23 09:01 robtherobot12

@robtherobot12 thanks for the reply :) is it still happening with latest mirror, or can we close this?

miwarnec avatar Apr 03 '23 15:04 miwarnec

@vis2k I'll check today, and write if so.

robtherobot12 avatar Apr 03 '23 16:04 robtherobot12

@Stolichnayer after experimenting, I realized that the error magically disappears if I move the network animator component to the very top to the network identity component in the hierarchy of components. the screenshots are more clear Screenshot_12 Screenshot_13

egorf710 avatar May 29 '23 06:05 egorf710

looking into this again. it can only happen if OnSerialize and OnDeserialize read/write different amounts of data. 2024-01-02 - 13-28-16@2x

miwarnec avatar Jan 02 '24 12:01 miwarnec

hey @Stolichnayer @robtherobot12 @egorf710 sorry for late reply. there's a pull request with a fix, which we will merge soon: https://github.com/MirrorNetworking/Mirror/pull/3711

this will 100% always serialize and deserialize the exact amount of data. and if parameters.count or layers.count is mismatching, it will show an exact error and let you know what went wrong.

miwarnec avatar Jan 02 '24 12:01 miwarnec