Offline mode #8

Closed
opened 2 years ago by utopiah · 12 comments
Owner

See previous work on cabin.html and deeper discussion on GDPR.

See previous work on `cabin.html` and deeper [discussion on GDPR](https://github.com/aframevr/aframe/issues/5119).
Poster
Owner

Partly solved via dependecies/ from 7632ad51e6

Partly solved via `dependecies/` from https://git.benetou.fr/utopiah/text-code-xr-engine/commit/7632ad51e6ec0b8d70297b135a745c6d4e719aa4
utopiah added the
demo
label 2 years ago
Poster
Owner
See the https://git.benetou.fr/utopiah/text-code-xr-engine/src/branch/minimum branch that can be tested live at https://fabien.benetou.fr/pub/home/future_of_text_demo/engine/branch_minimum.html .
Poster
Owner

See documentation on https://twitter.com/utopiah/status/1598333807941271553 :

See documentation on https://twitter.com/utopiah/status/1598333807941271553 : * `scrcpy` for mirroring, including wirelessly * modified AFrame for assets like hands models and fonts https://github.com/aframevr/aframe/pull/5118/commits/4813372f3ffc3c3921d454e8981817a5fdd87dc1 * same for some components, e.g `<a-troika-text>` https://github.com/lojjic/aframe-troika-text * `npm run dev` with NAF default adapter https://github.com/networked-aframe/networked-aframe
Poster
Owner

Process :

  1. open the browser console with its network tab
  2. disable cache
  3. reload page
  4. pause and copy the HAR (Http ARchive) trace
  5. in the console tab save the trace as the har variable
  6. parse it, cf example below, to find requests not on the current domain
  7. iterate until all requests necessary for the required featured are on the current domain
  8. iterate then with the right subdirectory, i.e relative links instead of absolute
  9. iterate in VR as some content might be pulled only then, e.g 3D models for hand tracking
outsideDomainURLs = har.log.entries
.filter( i => i.request.headers[0].value != window.location.hostname)
.map( r => r.request.url )

outsideSubdirectory = har.log.entries
.filter( i => i.request.headers[0].value == window.location.hostname && i.request.url.indexOf(window.location.pathname) < 0)
.map( r => r.request.url )

failedURLs = har.log.entries
.filter( i => i.response.status != 200)
.map( r => r.request.url )

console.log("\noutsideDomainURLs:", outsideDomainURLs, "\noutsideSubdirectory:", outsideSubdirectory, "\nfailedURLs:", failedURLs)

Can also take the occasion to make other requests optional with fallbacks.

Note that beside have local copies libraries might need to have a CDN or content URL updated accordingly, even forced in their bundled code if no such option is available. Overall it would be a good habit to document such dependencies beyond code.

To best check in VR use remote debugging from the browser to have logs again, modify then refresh.

Process : 1. open the browser console with its network tab 2. disable cache 3. reload page 4. pause and copy the HAR (Http ARchive) trace 5. in the console tab save the trace as the `har` variable 6. parse it, cf example below, to find requests not on the current domain 7. iterate until all requests necessary for the required featured are on the current domain 8. iterate then with the right subdirectory, i.e relative links instead of absolute 9. iterate in VR as some content might be pulled only then, e.g 3D models for hand tracking ```javascript outsideDomainURLs = har.log.entries .filter( i => i.request.headers[0].value != window.location.hostname) .map( r => r.request.url ) outsideSubdirectory = har.log.entries .filter( i => i.request.headers[0].value == window.location.hostname && i.request.url.indexOf(window.location.pathname) < 0) .map( r => r.request.url ) failedURLs = har.log.entries .filter( i => i.response.status != 200) .map( r => r.request.url ) console.log("\noutsideDomainURLs:", outsideDomainURLs, "\noutsideSubdirectory:", outsideSubdirectory, "\nfailedURLs:", failedURLs) ``` Can also take the occasion to make other requests optional with fallbacks. Note that beside have local copies libraries might need to have a CDN or content URL updated accordingly, even forced in their bundled code if no such option is available. Overall it would be a good habit to document such dependencies beyond code. To best check in VR use remote debugging from the browser to have logs again, modify then refresh.
Poster
Owner

Optionally consider the large files

largestFiles = har.log.entries
.sort( (a,b) => b.response.bodySize-a.response.bodySize )
.map( r => { return {size:r.response.bodySize/1000000+"Mb",url:r.request.url}} )
.slice(0,5)

Consider gltf-transform optimize with --compress none https://gltf-transform.donmccurdy.com/cli.html as Draco helps but isn't required.

Optionally consider the large files ```javascript largestFiles = har.log.entries .sort( (a,b) => b.response.bodySize-a.response.bodySize ) .map( r => { return {size:r.response.bodySize/1000000+"Mb",url:r.request.url}} ) .slice(0,5) ``` Consider `gltf-transform optimize` with `--compress none` https://gltf-transform.donmccurdy.com/cli.html as Draco helps but isn't required.
Poster
Owner

Should also consider a function or component template, or at least documented as good practice, insuring new features can reliably used offline with minimum setup.

Should also consider a function or component template, or at least documented as good practice, insuring new features can reliably used offline with minimum setup.
Poster
Owner

Example for shiki and <a-console> 841980a10c showing how convenient it can be.

Example for `shiki` and `<a-console>` https://git.benetou.fr/utopiah/text-code-xr-engine/commit/841980a10cfd3ce95c9f858d26b7ae038bd676ee showing how convenient it can be.
Poster
Owner

See also https://github.com/lojjic/aframe-troika-text/issues/72 setting defaultFontURL directly in hosted version and downloading the font in ../content/.

See also https://github.com/lojjic/aframe-troika-text/issues/72 setting `defaultFontURL` directly in hosted version and downloading the font in `../content/`.
Poster
Owner

Getting relative file list from parent directory

har.log.entries
.map(r=>r.request.url.replace("https://fabien.benetou.fr/pub/home/future_of_text_demo/",""))
.join("\n")

Should still add files loaded later, e.g hand and controller models in AFrame.

This can then be grabbed via tar -cvf offline.tar -T filestopack but will miss some like engine/leftHand.glb and engine/leftHand.glb but also controllers (which are rarely used, if ever packed).

Getting relative file list from parent directory ```javascript har.log.entries .map(r=>r.request.url.replace("https://fabien.benetou.fr/pub/home/future_of_text_demo/","")) .join("\n") ``` Should still add files loaded later, e.g hand and controller models in AFrame. This can then be grabbed via `tar -cvf offline.tar -T filestopack` but will miss some like `engine/leftHand.glb` and `engine/leftHand.glb` but also controllers (which are rarely used, if ever packed).
Poster
Owner

A deploy/build/packaged script should automate some steps, including replacing hardcoded values on some dependencies when CDN options are not available.

cd engine
curl https://aframe.io/releases/1.4.1/aframe.min.js | sed "s|https://cdn.aframe.io/controllers/oculus-hands/v4/||g" > dependencies/aframe.offline.min.js
wget https://cdn.aframe.io/controllers/oculus-hands/v4/left.glb -O left.glb 
wget https://cdn.aframe.io/controllers/oculus-hands/v4/right.glb -O right.glb
cd ..
tar -cvf offline.tar -T filestopack

meanwhile on the client it can be updated via

wget https://fabien.benetou.fr/pub/home/future_of_text_demo/offline.tar -O offline.tar && tar -xvf offline.tar
A deploy/build/packaged script should automate some steps, including replacing hardcoded values on some dependencies when CDN options are not available. ```bash cd engine curl https://aframe.io/releases/1.4.1/aframe.min.js | sed "s|https://cdn.aframe.io/controllers/oculus-hands/v4/||g" > dependencies/aframe.offline.min.js wget https://cdn.aframe.io/controllers/oculus-hands/v4/left.glb -O left.glb wget https://cdn.aframe.io/controllers/oculus-hands/v4/right.glb -O right.glb cd .. tar -cvf offline.tar -T filestopack ``` meanwhile on the client it can be updated via ```bash wget https://fabien.benetou.fr/pub/home/future_of_text_demo/offline.tar -O offline.tar && tar -xvf offline.tar ```
Poster
Owner

See also #40 including Gitea locally.

See also https://git.benetou.fr/utopiah/text-code-xr-engine/issues/40#issuecomment-400 including Gitea locally.
Poster
Owner

done multiple times during TADA workshops, documentation to write down but overall does work

done multiple times during TADA workshops, documentation to write down but overall does work
utopiah closed this issue 7 months ago
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: utopiah/text-code-xr-engine#8
Loading…
There is no content yet.