wtct-hungary / UnityVision-iOS

This native plugin enables Unity to take advantage of specific features of Core-ML and Vision Framework on the iOS platform.
MIT License
133 stars 26 forks source link

Freezes up intermittently on only one iPhone #6

Closed CharStiles closed 5 years ago

CharStiles commented 5 years ago

Hello, The classification app works on many phones but on one iPhone XS it freezes up. I was wondering if anyone had some ideas why.

So here are the details: iOS:12.2 The behavior is that it works for a few seconds then it freezes for 1-2 seconds and it works again, and this freezing continues.

I turned on Zombie Objects and get many of this error from the devices simulator console whenever it freezes 2019-03-20 12:58:34.740735-0400 snobBog3[7837:2621978] Execution of the command buffer was aborted due to an error during execution. Discarded (victim of GPU error/recovery) (IOAF code 5) I noticed I also get this warning before Tiled GPU perf. warning: RenderTexture color surface (1080x1920) was not cleared/discarded.

The problem is definitely is somewhere in the classification code, because all the AR stuff works when the vision script is disabled.

I have tried (that I can remember):

I tested it on a different iPhone XS and it works great.

I have never developed an app before that deals with swift or CoreML so anything you may seem as obvious to try may save me more weeks of headaches! Is there something I should be looking at that would tell me why it works on one iPhoneXS but not another?

Thanks for reading I anticipate & appreciate a response

adamhegedues commented 5 years ago

Hi CharStiles,

Could you please let me know how do you create or pass the CVPixelBuffer to the native component? I had this issue before when I used Metal textures on iOS 12.0 and it turned out to be a driver bug.

"I tested it on a different iPhone XS and it works great."

Are both of those iPhones on the same iOS version?

Best regards, Adam

CharStiles commented 5 years ago

Thank you for your fast response!

Char

adamhegedues commented 5 years ago

Hi,

I meant what example did you base your app on? There are 2 ARKit examples included in this repo.

Thanks, Adam

CharStiles commented 5 years ago

You mean classification vs rectangle? I mentioned I am using the classification example. Sorry I should have made that more clear :)

adamhegedues commented 5 years ago

There are actually 4 examples for classification. Two of them use ARKit. :)

https://github.com/possiblecee/UnityVision-iOS/blob/master/UnityVision-iOS/Assets/Scripts/Examples/ARKitExample.cs

https://github.com/possiblecee/UnityVision-iOS/blob/master/UnityVision-iOS/Assets/Scripts/Examples/ARKitExample2.cs

CharStiles commented 5 years ago

Ah! My apologies! I am using the first one (ARKitExample.cs).

adamhegedues commented 5 years ago

I pushed a change yesterday. The only file that's been modified is this: UnityVision-iOS/Assets/Scripts/Possible/Vision/Plugins/iOS/VisionNative.swift

Can you please pull and try to see if your problem persists? If this doesn't solve the issue, try using the second example.

Also, did you find out the version numbers on those iPhones?

Thanks, Adam

CharStiles commented 5 years ago

Hi Adam, I had a meeting with the person with the problematic iPhone, and THANK YOU the new script worked like a charm!

The version number is A1920. Also I mentioned a while back that I inquired if the other non-problematic iPhone XS had the same iOS version, he said he doesnt remember, alas.

So my naive stab at what you have done is replace the buffer that holds the pixels from the camera from ciImage to cvPixelBuffer? I am in awe at how quickly and efficiently you solved my problem.

Thank you again,

Char