Start a new topic

Disabling Camera when tracking object causes bugs

When tracking is active on an object and augmented reality elements are rendering, if I disable the camera, the camera feed stop normally. But then it is not possible to re-activate it again. Nothing happens when I try to do so, the camera feed is responding and no errors are thrown. 


To activate / deactivate the camera I used the respective commands 

 

AR.hardware.camera.enabled = false;

AR.hardware.camera.enabled = true;

I have this behavior on a iPad 2017 on iOS 11.2.5 with SDK 7.2 (but I think this bug was also present on SDK 7.1).




I don't know if that is related, but I also noticed that sometime the camera feed / get frozen as soon as an object is recognized, when the camera has been disabled and re-enabled before. I never had this problem on SDK 7.2.

To reproduce this bug with the sample app : 

- run the "Basic Object Tracking" demo

- track the truck

- from a computer, via web inspector (safari), access the javascript console of the AR WebView.

- run "AR.hardware.camera.enabled = false;" while tracking the truck
- wait a bit

- run "AR.hardware.camera.enabled = true;"

- => the camera feed is not reactivated. 

@wikitude : can you reproduce the bug I mentioned on your side ?

Hi Amaury,

Unfortunately not. Could you send us a video where we see how you reproduce the issue?


We added such a snippet to the architect world to make it easier to initiate the camera pause:

AR.context.onScreenClick = function() {


    AR.hardware.camera.enabled = false;

    setTimeout(function(){ AR.hardware.camera.enabled = true;}, 3000);

}


Best regards,

Andreas

Thanks for testing it. 


Indeed your code runs well on my device.  If I change it to stress the system like this the bug reappears :

  

AR.context.onScreenClick = function() {

    AR.hardware.camera.enabled = false;

    setTimeout(function(){  AR.hardware.camera.enabled = true;}, 1500);
    setTimeout(function(){  AR.hardware.camera.enabled = false;}, 3000);
    setTimeout(function(){  AR.hardware.camera.enabled = true;}, 4500);
    setTimeout(function(){  AR.hardware.camera.enabled = false;}, 6000);
    setTimeout(function(){  AR.hardware.camera.enabled = true;}, 7500);
    setTimeout(function(){  AR.hardware.camera.enabled = false;}, 9000);
    setTimeout(function(){  AR.hardware.camera.enabled = true;}, 10500);
    setTimeout(function(){  AR.hardware.camera.enabled = false;}, 12000);
    setTimeout(function(){  AR.hardware.camera.enabled = true;}, 13500);

}

I manage to get around 4 switches on my iPad (2017) and then the app freezes. If I move/shake the device while tracking, or if I open safari web inspector on the webview, I only manage to get 1 or 2 switches max. So I think it depends on device CPU/Memory usage maybe. In our app which is quite heavy, we are very careful about not switching the camera too often (not every 1.5 s like in the crazy exemple above), and the bug appears regularly.


NB : switching camera off is important for us in order to preserve users' battery. We can't close the AR WebView as our app is running in it.

Hi Amaury,

I ran your snippet on an iPhone 6 Plus and it was fine as you can see in the attached video. Can you please send such a screen recording as well?!

Since you mentioned memory usage: Could you also please attach the Xcode console log? Would be interesting to see if it mentions something important.


Best regards,

Andreas

mov
Login or Signup to post a comment