Update system-arjs.js / Aframe Build / Exponential Backoff #304
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added exponential backoff function to the Aframe build (system-arjs.js)
What kind of change does this PR introduce?
I have added a simple exponential backoff function to the Aframe build (system-arjs.js)
Can it be referenced to an Issue? If so what is the issue # ?
No, this PR was not made in response to an issue.
How can we test it?
If you build/make the Aframe version of ar.js and are able to use it, it should be working correctly. The previous build used a setInterval function to resize the ar.js document element - this setInterval function fired every 33.3 seconds, and had a maximum duration of several hours. The function I made to replace it will fire at 33.3 millis, 66.6 millis, 133.2 millis, etc --- doubling every time, until a limit is hit (by default, 1 second, as noted in the comments requesting this feature)
It also has a maximum duration setting, but by default it will run forever (duration is set to Infinity by default).
Summary
I saw in the comments that an exponential backoff function was intended, but not yet written - So I made one (setBackoff). I tested the build and it works (more info below). Much like setTimeout & setInterval, setBackoff takes a function and a duration. The duration is set to Infinity by default, meaning the code will continue to repeat without limit. If a duration is provided, it will be called until that duration is exceeded. The final optional parameter sets the limit or ceiling for the backoff in milliseconds. The default value is 1000 (1 second), meaning the greatest interval of the backoff will not exceed 1 second.
Does this PR introduce a breaking change?
No, this change requires no refactoring.
Please TEST your PR before proposing it. Specify here what device you have used for tests, version of OS and version of Browser
To test, I created a new build of aframe-ar.js that included my changes. I then used the new build in one of the example projects for Aframe (ar.js/aframe/examples/marker-based/basic.html).
There were no errors in the web console, and I was able to make the TREX model appear over the hiro marker, as expected. I did this both on my machine (win10, using a webcam) and my device (android chrome).
Tested on Windows 10 Home version 20H2, 64-bit operating system, x64-based processor (Browser: Firefox 89.0.2)
Tested on Pixel 2, Android 11 (Browser: Chrome 91.0.4472.120)
Other information
N/A