MixedRealityToolkit-Unity icon indicating copy to clipboard operation
MixedRealityToolkit-Unity copied to clipboard

NearMenu/RadialView/Solvers break in ARM64 Release mode

Open ei2kpi-ptc opened this issue 6 years ago • 78 comments

Describe the bug

In the NearMenuExampleScene, there seems to be a race condition causing an issue only seen in Release mode ARM64 where the menus disappear from view when they are unpinned.

During investigations, I noticed that the scale of the menu would go to (0,0,0.3) instead of 1,1,1 causing the menu to disappear completely or sometimes, the menu would be stuck at a weird angle for a bit and then disappear completely.

It looks like the issue is related to RadialView since I found it when I was upgrading a project from v2.0.0 to v2.3.3 and my menu bar was never showing up since it had RadialView on it. So, it does not seem related to the NearMenu prefabs in any way. After a ton of debugging, I realized it was happening in the stock MRTK repo itself.

The issue seems to repro only with ARM64, Release and when the app is built in Unity without development mode on. It does not repro when built for ARM, or when built for Debug or when built with Unity Development Mode + Script debugging.

To reproduce

A) Clone the repo, open and build the NearMenuExamples scene for ARM64, Release and deploy to a HL2. Try to unpin one or more of the menus displayed in the scene

B) Create a new project in Unity using the instructions in the Getting Started guide and import the MRTK Foundation and MRTK Examples packages. Then, build for ARM64, Release and deploy to HL2. Try to unpin one or more of the menus displayed in the scene.

Expected behavior

See videos below

Videos

REPRO: Arm64, Release, Vanilla Project with MRTK unitypackages: https://youtu.be/WAaUk4ChLkk REPRO: Arm64, Release, MRTK Repo checked out at v2.3.0: https://youtu.be/tMJBf6YXvLM

NO REPRO: Arm64, Debug, Vanilla Project with MRTK unitypackages: https://youtu.be/XlW5iN6SEgM NO REPRO: Arm64, Debug, MRTK Repo checked out at v2.3.0: https://youtu.be/BoffJwdd0X4

Your setup (please complete the following information)

  • Unity Version 2019.3.7f1
  • MRTK Version v2.3.0

Target platform (please complete the following information)

  • HoloLens 2, ARM64, Release

ei2kpi-ptc avatar Apr 07 '20 21:04 ei2kpi-ptc

Interesting...the combination of repro scenarios you lay out makes me think there's some race condition somewhere? In slower configurations (ARM vs ARM64, debug vs release, development mode vs not) it doesn't repro, but does in ARM64 + release.

keveleigh avatar Apr 08 '20 18:04 keveleigh

Agree...

My initial hunch was that it might have something to do with the RadialView Maintain initial scale option but as you can see in the repro videos, sometimes it is not just the scale that gets zeroed out, sometimes it is the orientation that gets locked in a weird way.

Another (probably lower chance) possibility is that some code optimization between release / debug or casting between 64-bit and 32-bit might be causing things to go awry?

ei2kpi-ptc avatar Apr 09 '20 17:04 ei2kpi-ptc

BTW, I upgraded my project from MRTK v2.0.0 to v2.3.0 when this started happening and the RadialView.cs script has very minimal changes between those two versions. So, this is something a bit more complicated I'm afraid.

ei2kpi-ptc avatar Apr 09 '20 17:04 ei2kpi-ptc

BTW, I upgraded my project from MRTK v2.0.0 to v2.3.0 when this started happening

Did you update Unity versions as well, or just MRTK around that time?

keveleigh avatar Apr 13 '20 16:04 keveleigh

I did go from Unity 2019.2.13f1 to Unity 2019.3.7f1 as well.

ei2kpi-ptc avatar Apr 13 '20 17:04 ei2kpi-ptc

I can confirm this issue for different menus we have on our app.. For me the simpliest way to reproduce is:

  • empty project (Unity 2019.2.15 )
  • import Microsoft.MixedReality.Toolkit.Unity.Foundation.2.3.0.unitypackage
  • configure Sample scene and project(just using MRTK provided)
  • adding "Windows Mixed Reality" under Virtual Reality SDKs (this is another problem ;) )
  • adding "simple hand palm menu" only to display a sphere when the palm is tracked image image (I've marked everything I've changed after adding the Scripts)

When deploying Release|ARM64 the Sphere does not show up (as described above) when using "slower" build settings it does show up.

Hope this helps to track this down! :)

cefoot avatar Apr 14 '20 05:04 cefoot

Sorry, I just noticed that for now the issue was only mentioning radial view but my guess is, that my comment is still valid as this seems to infect more than radial view only.

cefoot avatar Apr 14 '20 06:04 cefoot

我也碰到这个问题。

flaidxu avatar Apr 14 '20 08:04 flaidxu

Hi, I think this was what I experienced with my project for Hololens 2. And when having a solver with smoothing enabled (eg. HandMenu, HandConstraintPalmUp) the menu would "disappear" prob. going to scale 0 as described. When I disabled the smoothing the hand menu did not disappear any more and followed the hand as expected, although a little choppy without the smoothing.

Had the Hololens 2 for a couple of weeks to try it out and can't test on it anymore. But the smoothing worked fine in the editor play mode, but not when deployed to the HL2. Built with Master|ARM64 I think...

I also recall that there were some other component that had similar problem, I think it was the surface magnetism as well (the object disappeared when the magnetism was activated), and when disabling the smoothing then it worked as expected again. This can maybe help you a little further.

Cheers,

c11epm avatar Apr 14 '20 12:04 c11epm

yes @c11epm that solves it for me (with different solvers I use) thanks! If I've time later I'll try to track this down!

cefoot avatar Apr 14 '20 13:04 cefoot

@cefoot and @c11epm , I unchecked the" Smoothed Eye Tracking"setting in the Eye Gaze Provider section of the Configuration Profile and that fixed it. Even though I did not change the smoothing setting in my Radial View components.

I think this also happened on a different occasion when I had RadialView components both on the parent AND a child object simultaneusly, but that seemed like a reasonable outcome.

tank-t-bird avatar Apr 20 '20 17:04 tank-t-bird

I confirmed this in 2019.3.10f1.

This looks like and IL2CPP bug (or god forbid an ARM64 compiler bug) when generating code for Solver.UpdateWorkingScaleToGoal or UpdateWorkingPositionToGoal. The 'GoalPosition' value from the previous call to UpdateWorkingPositionToGoal appears to be reused/overwriting the 'GoalScale' value being passed into the call to the SmoothTo method. This is super strange, the generated IL2CPP code looks as sane as it ever does, and I can't see how it's blatting or re-using values from the previous call.

In my case, the the position update was setting a GoalPositon of (0.0, 0.0, 0.1) which was then flattening out some objects when it was applied to the GoalScale.

The work around suggested above works.

If there is anybody left in Seattle I'd suggest trying to work out what the heck, as SmoothTo is used in a few places and might produce weird behavior elsewhere.

matware avatar Apr 27 '20 11:04 matware

From the HoloDevelopers Slack mixed-reality-toolkit channel: Annotation 2020-04-28 154211

tank-t-bird avatar Apr 28 '20 13:04 tank-t-bird

What I found out, that if I build the exact same VS solution from Visual studio 2019 16.4.5 -> hand menu works, Visual studio 2019 16.5.4 -> hand menu dissapears. Unity version 2019.2.21f1, MRTK: 2.2.0

So I think it's more of a visuals studio bug than an MRTK bug.

HerrKatzen avatar Apr 29 '20 08:04 HerrKatzen

I can confirm I was using VS2019.5.4, well snap ARM64 compiler bug? I'll try and test ARM tomorrow (but I Unity 2019.3 ARM builds were broken last time I checked). edit: ARM is still broken in Unity 2019.3 so can't check.

matware avatar Apr 29 '20 12:04 matware

@keveleigh Did we find any more information about this bug? I hit this bug in an app that was upgraded to MRTK 2.3. Created a new scene with just a Slate: It scales to zero as soon as the "Follow me" button is hit. The hand menu solvers also scale to zero.

Building with ARM solved the issue. I had also tried reinstalling MRTK from Nuget and that seemed to fix the issue for some reason...

srinjoym avatar May 07 '20 16:05 srinjoym

@srinjoym Unfortunately, I haven't had time to really dig in yet.

upgraded to MRTK 2.3

Which version were you upgrading from? And did you happen to change Unity versions at the same time?

I had also tried reinstalling MRTK from Nuget and that seemed to fix the issue for some reason...

Huh...

keveleigh avatar May 07 '20 16:05 keveleigh

@matware, for ARM builds with Unity 2019.3, can you try following the steps documented in #7888 (disable Graphics Jobs in the player settings)?

Thanks!

david-c-kline avatar May 15 '20 17:05 david-c-kline

I have yet to be able to repro this with Unity 2018.4.x and Visual Studio 16.5.5 (granted, this was targeting ARM not ARM64). I built both Release and Master flavors.

I will try again using 2019.3.x and ARM64.

david-c-kline avatar May 15 '20 23:05 david-c-kline

I can confirm I was using VS2019.5.4, well snap ARM64 compiler bug?

@matware, can you try installing the 16.5.5 release of VS and let us know if you see the same issue? I would recommend a clean build to ensure that if this is a compiler issue, there is nothing left over :)

david-c-kline avatar May 15 '20 23:05 david-c-kline