Hello,
I am working for a while now with the Holo Lens.
Suddenly the program I am working on stopped running on the Holo Lens.
It is deployed successfully on the Holo Lens, but after the Debug Session in Visual Studio starts, the program is immediatly terminated with a “Screen position out of view frustum” error.
I have nailed down the error and the reason for the error really confuses me.
Here are the steps to reproduce the error in a simple test program:
Make a new empty hololens project with a cube in the middle.
Deploy it on the hololens and check that it works. I use “Debug/x86/Remote Machine” as configuration.
So now as we have certified that the program works let’s break it
Create a new script and add an empty method called OnMouseDown()
void OnMouseDown()
{
}
Don’t attach the script to anything!
Deploy again on the holo lens.
The following error pops up in Visual Studio after the app is already runnig on the hololens. Afterwards the app is immediatly closed.
Screen position out of view frustum (screen pos 0.000000, 0.000000) (Camera rect 0 0 1268 720)
(Filename: C:\buildslave\unity\build\Runtime/Camera/Camera.cpp Line: 2626)
The program ‘[4740] onmousedowntest.exe’ has exited with code -2147483645 (0x80000003).
My setup:
Windows 10 Pro 1703 (Build 15063.483)
Visual Studio 2015 14.0.25431.01 Update 3
Unity 5.6.2f1
Am I the only one who gets this error in such a simple program?
Can anyone explain to me why a script that is not used, with a method that is empty, can create such an error?
The only thing I had to do to make the error go away is to rename OnMouseDown to OnMyMouseDown.
When you look closely at the screenshot you can see that there is a message from Unity:
Game scripts or other custom code contains OnMouse_ event handlers. Presence of such handlers might impact performance on handheld devices.
UnityEditor.HostView:OnGUI()
I don’t think this message should mean that it will not run on the holo lens.
The real thing that bugs me is why does this message come at all?
The script is not attached and never called. It is just “lying” around in the project space.
Everything works fine in Unity, it is only after the deployment to the holo lens when the program immediatly exits with the error code.
Yes, OnMouseDown is a registered MonoBehavior handler, so it’s behavior under the hood is different to a regular function. Higher level handlers (those dependent on higher scope than engine) need to be bound before the games per frame running. They are also probably bound even if script is not active in scene (they must be if your script was not in the scene).
So I’m assuming at execution start: if any reference to OnMouseDown exists in any script: unity engine registers a single mouse hook with underlying OS (ready to serve to any active MonoBehaviors that may exist in future), and at that time the higher level hololens system is not ready to give out an input hook.
Regardless; it should not fail catastrophically, but rather log out an error and keep running, you may want to report the bug at the relevant place: Hololens unity SDK team.
As a work around I would not use callback handler for inputs from hololens: instead poll unity inputs per frame, in update:
You should be able to use all engine contained handlers (like update etc) without problems. But handlers listening for HoloLens state may fail.
Is there a way to know beforehand which methods are listening for the HoloLens state?
Until now I just used all the unity callbacks without much thinking about it.
For me this is an opportunity to learn and understand more of whats actually happening behind the scenes.
Btw. how could you look at: Camera.cpp line 2626?
When I click “go to definition” nothing happens.
Any OnXXX handlers that read HoloLens state may exhibit same bug, but then they may be fine, perhaps its just mouse? If it runs it’s good I suppose!
Well I’m not your best teacher, I’m assuming the above. But that would be fairly standard procedure for any system using external hooks: bound at instance start once, propogated internally as needed.
OK, I didn’t read the full path, it’s debug info for unity engine, we don’t have source, assumed it was hololens SDK code to which you may have access to source.