jeromeetienne / AR.js

Efficient Augmented Reality for the Web - 60fps on mobile!
MIT License
15.79k stars 2.22k forks source link

1.7.8 Marker not working on different sized windows #579

Closed ghost closed 4 years ago

ghost commented 5 years ago

Describe the bug With the latest release, when you resize the window from responsive to anything else such as the iPhone x and refresh, the marker will no longer recognise. It will only recognise when you go back to responsive and expand the window.

To Reproduce

<!doctype HTML>
<html>
<script src="Scripts/aframe.min.js"></script>
<script src="Scripts/aframe-ar.min.js"></script>
  <body style='margin : 0px; overflow: hidden;'>
    <a-scene embedded arjs>
      <a-marker preset="hiro">
          <a-box position='0 0.5 0' material='color: yellow;'></a-box>
      </a-marker>
      <a-entity camera></a-entity>
    </a-scene>
  </body>
</html>
  1. Copy paste code
  2. Open in chrome and hit F12
  3. The marker should be recognised on responsive
  4. Switch to a different device then refresh

Desktop (please complete the following information):

nicolocarpignoli commented 5 years ago

It could be a bug introduced with this change: https://github.com/jeromeetienne/AR.js/commit/788d27310cb89be906506a7abbdbfd593a9303ac#diff-18f0a7b3260cc3d69ec53e05b9227d6bL244

don't mind all the modifies, the snippet interested is at line 244

//////////////////////////////////////////////////////////////////////////////
        //      Code Separator
        //////////////////////////////////////////////////////////////////////////////
// TODO this is crappy - code an exponential backoff - max 1 seconds
        // KLUDGE: kludge to write a 'resize' event
        var startedAt = Date.now()
        var timerId = setInterval(function(){
            if( Date.now() - startedAt > 10000*1000 ){
                clearInterval(timerId)
                return
            }
            // onResize()
            window.dispatchEvent(new Event('resize'));
        }, 1000/30)
    },

I guess removing this cause an error. strange.

the bug for which we introduced that fix was: https://github.com/jeromeetienne/AR.js/issues/574

@cconnor12345 in the meantime you can use older version, they do not have this bug @kalwalt what do you think about that?

kalwalt commented 5 years ago

@nicolocarpignoli at the moment i have no idea. But could be interesting to see if this happens even on Smartphone devices.

nicolocarpignoli commented 5 years ago

on smartphones the only possible resize is changing landscape to portrait and back, have to test this

jonasjohansson commented 5 years ago

Tested this on two different devices, been driving me mad for the past hour.

1.7.7 works fine, 1.7.8 forces resize/orientation change etc. for the marker to get detected and display contents. Even the Codepen example is using 1.7.5 (aframe ar).

nicolocarpignoli commented 5 years ago

I have very poor time this days. I can switch back to version 1.7.7 on Master but the resize event bug will pop up again doing that. I don't know, in the meantime the most stable version is 1.7.5 and 1.7.7, I suggest using them for now

nicolocarpignoli commented 5 years ago

ok try again please. Now I reverted back modifies. YOu can use version 1.7.8 that now should be stable. It contains the performances problems tho. When I will have time I can look for it again. For now, it's important to have a stable version as latest version and on master branch