arfoundation-samples icon indicating copy to clipboard operation
arfoundation-samples copied to clipboard

MutableRuntimeReferenceImageLibrary not working in Android

Open jiungerich opened this issue 6 years ago • 16 comments

I have code that implements a MutableRuntimeReferenceImageLibrary and for iOS it works beautifully - frankly I am very very happy with it. However, the exact same code complied to an Andriod phone executes but the images never actually get added to to the reference image library. I have debug flags going to a canvas during the ScheduleAddImageJob. These show that this is happening on both iOS and Android using the jobhandle.

But when I list out the images in the reference library to see what was added at the end, I only get images added to iOS device. This also shows when I go to check tracking as the android phone only tracks the 1 image that was already in the library before i made it mutable.

I also check if the android device is supports MutatableLibrary by using the subsystme descriptor and this returns true. I have no idea why the image does not get added.

I am using Unity 2019.3.12f1. AR foundation 3.1.3, AR Subsystems 3.1.3 ArCore 3.1.3 and ArKit 3.1.3

jiungerich avatar May 26 '20 23:05 jiungerich

Also not sure if this is related - but if I try to call trackImageManager.CreateRuntimeLibrary(runtimeImageLibrary) on the android phone I just a get a black screen when I try to run the scene. The andriod device I am testing on is a Galaxy 7 phone.

jiungerich avatar May 26 '20 23:05 jiungerich

I confirmed that I have the same issue on a galaxy 9 as well.

jiungerich avatar May 27 '20 11:05 jiungerich

Hi-

It's possible that the image may not be recognizable by ARCore independent of the ReferenceImageLibrary being mutable. Please test the image using an XRReferenceImage library in the editor and confirm that ARCore can recognize it.

-Mike

mdurand42 avatar May 28 '20 22:05 mdurand42

Hi-

It's possible that the image may not be recognizable by ARCore independent of the ReferenceImageLibrary being mutable. Please test the image using an XRReferenceImage library in the editor and confirm that ARCore can recognize it.

-Mike

Hello Mike,

All the test images I am using work fine in a standard library. I have a whole set of ones that know pass and do not pass. The ones not adding are all in the pass and I have built several non-runtime libraries with them and they work fine.

Also - if they are not compatible the AddImageJob they would throw an exception. Instead as I mentioned above, I do not get an exception but I instead get a job handle that returns every completed just fine.

-Jonathan

jiungerich avatar May 29 '20 01:05 jiungerich

Is there reference or demo script for the mutable runtime libraries? - this would be very helpful in debugging issues or just comparing code. I have found references for most everything else I need for ARFoundation - did I miss this one? This is the one key area that is keeping me for releasing on Andriod so I am very keen to make something work.

jiungerich avatar Jun 07 '20 18:06 jiungerich

So I have been doing some more testing on this. I have been getting the mutable runtime libraries to work now - sometimes. This does not work reliably at all. Sometimes the images are recognized fine but then I reload the scene with the viewer and mutable library and it doesn't work at all. Sometimes it works for some pictures. Sometimes it works right away for everything. Sometimes it takes a while and then picks something up. Just no consistency. I am wondering if the recognition algorithm somehow gets applied differently to the same picture when run in different instances. I never seem to know when it will or will not track. There are some other treads speaking about the inconsistency of tracking in android, this is likely all the same issue, just that in my first few cases I was getting nothing. Although odd that the AddImage job was returning completed. Everything is functioning excellent if I switch the build to iOS.

jiungerich avatar Jun 08 '20 14:06 jiungerich

The RuntimeReferenceImageLibrary (MutableRuntimeReferenceImageLibrary ) works very well on iOS. But on Android, the tracking is not as fast as local referenceimagelibrary, the tracking state will be none and it takes around 10s to change the state to tracked. I have tested on Pixel2-3 and Samsung A50 Also I have updated to ARfondation 4.0.2, but the runtime libraries still not work very well. Is there any solution?

jujugy avatar Jul 09 '20 03:07 jujugy

The RuntimeReferenceImageLibrary (MutableRuntimeReferenceImageLibrary ) works very well on iOS. But on Android, the tracking is not as fast as local referenceimagelibrary, the tracking state will be none and it takes around 10s to change the state to tracked. I have tested on Pixel2-3 and Samsung A50 Also I have updated to ARfondation 4.0.2, but the runtime libraries still not work very well. Is there any solution?

After looking into this more, it looks like the problem is in ARCore and not Unity. The runtime images likely will not work well on Andriod until Google fixes it. Would be nice if Unity had a way just to compile a non-runtime library at runtime, then you could just set the library to that. That would solve most of the AR Core tracked image issues. I actually applied for some grant funding to make a unity plugin to do just that. I will see if it comes in. A lot of people having this issue. I can not do a full release on my app on Google play because of this error.

jiungerich avatar Jul 09 '20 13:07 jiungerich

@jiungerich Can you please explain how you came to the conclusion that this is an issue with ARCore. I don't doubt you but I am curious how you made that determination. Thanks.

mdurand42 avatar Jul 11 '20 00:07 mdurand42

@jiungerich Also, if I understand correctly, you propose to develop a plugin that compiles runtime reference libraries the same way as statically included reference libraries? Is there actually a way to do that, and if so, why is that currently not the method for runtime libraries too?

Edit: Forgot to add my 2 cents: I too am seeing this issue. Tracking is working, however, on android it takes a while before my trackables get their full pose information. For me, this issue also only exists with the runtime library. The strange part is, that I have used ARCore without Unity in the past and runtime tracking was notably faster on the same device, with the same trackables.

Hless avatar Jul 11 '20 06:07 Hless

@jiungerich Can you please explain how you came to the conclusion that this is an issue with ARCore. I don't doubt you but I am curious how you made that determination. Thanks.

It isn't solid knowledge but mostly inference. It "looks" like the problem is there but I do not know all the details of the underlying code to be certain. All signs point in that direction.

The add image at runtime method is native to ARCore and from what I understand from all the Unity documentation AR foundation just sits on top of that. If Unity was doing something other than calling the AR Core addimage method I would be surprised. Although while it possibly could be some issue in the further abstraction that Unity does, there are also people mentioning some issues with the runtime functions on the ARCore GitHub; so I think it is unlikely. But there are many other issues with the Andriod tracking beyond the AR tracking intermittence. Such as the image usually tracks and calls the prefab if the camera is looking at the image when the AR tracker is started, but sometimes has trouble finding the image if it is not in view at the start. Then it if you go to a second tracked image, it has trouble picking up the first one again (as in it pretty much never tracks the image it was tracking previously). Then the fact that AR core is way behind in many other areas of AR; it just does not seem very developed in comparison to other AR SDKs.

jiungerich avatar Jul 11 '20 22:07 jiungerich

@jiungerich Also, if I understand correctly, you propose to develop a plugin that compiles runtime reference libraries the same way as statically included reference libraries? Is there actually a way to do that, and if so, why is that currently not the method for runtime libraries too?

Edit: Forgot to add my 2 cents: I too am seeing this issue. Tracking is working, however, on android it takes a while before my trackables get their full pose information. For me, this issue also only exists with the runtime library. The strange part is, that I have used ARCore without Unity in the past and runtime tracking was notably faster on the same device, with the same trackables.

This is correct, although just clarifying that it would be compiling an actual static library, the same way the ARCore image tool does or Unity does but allow you to do it in your program as a method. There are some people who have had success doing this by putting the ARCore image tool in the cloud and then making a call to it. A bit more complex to use a workaround like this for ARKit as these functions are embedded in XCode. It may require creating its own tracked image manager to make it all work cross-platform, This can be done- just a lot of work, which is why I went for grant funding.

As to why this not there already, I do not know.

jiungerich avatar Jul 11 '20 23:07 jiungerich

Okay, so, I too have been testing a bit last couple of days. One thing I noticed is that my runtime trackables performed significantly better when I disabled 'Light estimation' on the AR Camera Manager. I'm using a Huawei Mate 20 lite as my testing phone, perhaps Light Estimation eats up too much CPU for the tracking to keep working correctly.

Has anyone else tried disabling Light Estimation features? (they are enabled by default if I'm correct)

Hless avatar Jul 14 '20 14:07 Hless

There are some people who have had success doing this by putting the ARCore image tool in the cloud and then making a call to it.

This would mean that you'd always need an active internet connection to initialise a static image library? That would also require a reliable web service, or would require users to host their own ARCore image tool, correct? Even though it could solve issues with the tracking performance, it's definitely still a suboptimal solution.

I suppose ARKit would not need this kind of implementation since runtime tracking on iOS seems to be working superbly.

Hless avatar Jul 14 '20 14:07 Hless

Hi,

I ran into the same issue. On iOS it is working superb but on Android (version 8) Samsung S8 the image targets are not recognized at all. I am using Unity 2019.4.4F1 with AR foundation 3.1.3

Will updating AR Foundation to version 4.x solve the problem? Or is it something Android specific?

bakkermark avatar Jul 21 '20 13:07 bakkermark

We're having the same issues, only for us it is very consistent. Some images will never work (but absolutely no feedback) and some will always work. Android issue only, works flawlessly on iOS. Tested on 4.0.1 and 4.1.0 preview 6, same issues.

Very annoying, we're trying to work towards a final product, but this bug is a game breaker...

DominicdeGraaf avatar Aug 06 '20 14:08 DominicdeGraaf