Search Unity

Bug Target group composer with dolly has a weird issue

Discussion in 'Cinemachine' started by Yuchen_Chang, Oct 4, 2022.

  1. Yuchen_Chang

    Yuchen_Chang

    Joined:
    Apr 24, 2020
    Posts:
    127
    Hello!
    I've encountered a super weird issue in TargetGroup + GroupComposer Virtual Camera.
    When I set the AdjustmentMode of GroupComposer to "Dolly Only" or "Dolly then Zoom", the camera is trying to put itself to the same place of target group. Most important, the issue happens only "sometimes". It sometimes works properly (like normal dolly), but sometimes the bug appeared, with exact same steps.
    Moreover, even in the normally-working condition, if I shutdown the unity editor and re-open (without any scene or project changes), sometimes the bug reappears.

    I've took a video of the simplest steps to reproduce the bug. (but even with the same steps, it sometimes works)


    I'm using m1-pro mac book pro, Unity version 2021.3.8 or 2022.1.0, and Cinemachine version 2.8.9.
    (And by the way, I haven't encountered this bug in my Windows computer, but I'm not sure if it is an OS / CPU chip issue)

    Is this a known bug?
    Thanks ahead for your reply.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    It's not a known bug. Can you send me your small repro project?
     
  3. Yuchen_Chang

    Yuchen_Chang

    Joined:
    Apr 24, 2020
    Posts:
    127
    Thank you for the fast reply!
    The attached file is the reproducing project. If a bug report is better, I can make a bug report.
     

    Attached Files:

  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    Thanks for the upload, but I cannot repro the problem. It's unlikely to be processor-related, in my opinion. I will keep trying from time to time.
     
    Yuchen_Chang likes this.
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    I still can't repro this. If you get any more information that might help, please send it.
     
    Yuchen_Chang likes this.
  6. Yuchen_Chang

    Yuchen_Chang

    Joined:
    Apr 24, 2020
    Posts:
    127
    Hello!
    Thanks for your continuous testing.

    I have some more information to share, but I think this problem may only happen on my mac / specific computers (due to its weird behavior), so maybe the dev team can lower the priority of this issue, or even ignore it.
    Also I forgot to say that I'm using m1 pro mac, but Intel edition of Unity Editor instead of Silicon, due to a bug that Silicon Unity Editor can't load some native dll.
    edit: I've found another person reported the same bug (Issue UUM-10178), and it has the same environment(m1 mac, but Intel Unity Editor).

    For other who may encounter the same problem, a quick solution is to turn the debug mode on (the bug icon in the right bottom of Unity), and it will start behave properly.

    debug-mode-on.png

    ---

    So, to find out the reason, I put the Package Cache of Cinemachine 2.8.9 into Assets folder (in order to add Debug.Log()) and Log the calculations to see where the problem is. The problem seems to be at line-217 of
    CinemachineGroupComposer.cs
    , which is calculating the targetDistance local variable for further calculation.
    Here comes the weird part. Whenever I Log the targetDistance value to the Console, it immediately behaves normally, like normal dolly, but if I deleted the log line, the issue again appears. (I didn't change any logic! just logging)

    Next, I tried to indirectly get the value of targetDistance by logging the results of the relative calculation, not targetDistance itself.
    (sorry for the messy codes)

    log-code.png

    and it gives me the following log output:

    log-output.png


    the second line shows "-10 = targetDistance - 10", which means targetDistance is 0,
    but that is literally impossible, because in any condition, targetDistance should be clamped to min value 1.5, due to the first line.

    It is like if I don't check the value of targetDistance, C# won't calculate targetDistance at all, and leave it to default value 0.

    Since the issue is beyond coding, I think there is no short way to fix this.
    Turning on the debug mode lets C# "inspect" the value of any local variable for breakpoint-debugging, making the variable be calculated, and hence start working properly.
     
    Last edited: Oct 19, 2022
  7. Yuchen_Chang

    Yuchen_Chang

    Joined:
    Apr 24, 2020
    Posts:
    127
    @Gregoryl just a bump in case the notification wasn't sent :)
    I've wrote my test result (and temporary solution) in the above reply, please check when you have time.
    Brief answer: I think it only occurs on "m1 mac + Intel (not Silicon) Unity editor"
    Solution: turn on the C# script debugging mode
     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    Thanks for the update. It does indeed look like a mac-only c# thing. Since I don't have a mac, I can't dig into this or find a workaround. Because this issue was reported elsewhere, the appropriate teams will be looking into it - assuming it's the same issue. As you have a reliable repro, you might want to also log an issue.
     
    Yuchen_Chang likes this.