aws-samples / amazon-sumerian-hosts

Amazon Sumerian Hosts (Hosts) is an experimental open source project that aims to make it easy to create interactive animated 3D characters for Babylon.js, three.js, and other web 3D frameworks. It leverages AWS services including Amazon Polly (text-to-speech) and Amazon Lex (chatbot).
MIT No Attribution
175 stars 80 forks source link

fix for syntax regression in Meta Oculus Quest Browser #180

Open trusktr opened 10 months ago

trusktr commented 10 months ago

[!NOTE] This is branched off of the branch for

  • 181

That pull request can be merged first to fix the build, but the build for this branch also works (no build!). For convenience, here's the diff between the branches as the Files changed tab will not be as convenient.

Description

For whatever reason, depending on the URL used to visit the app in Oculus Browser (f.e. a deployment using an HTTPS domain, vs running via localhost or an IP address), the return values of .keys() and .values() methods for Map, Set, and Array will cause a syntax error when spread into an array.

For example, when Oculus Browser gets into this broken state, this code

const array = [...( new Set( [1, 2, 3] ).keys() )]

will cause this error to be thrown:

Uncaught TypeError: Set.keys is not a function or its return value is not iterable

Sometimes the problem does not happen, depending on how an app is accessed, but I'm not sure exactly what causes it.

Converting code like [...set.keys()] to Array.from(set.keys()) works around the issue in Oculus Browser.

Related Issue \

N/A

Reviewer Testing Instructions

Try deploying the test example to some server, f.e. on nodechef.com, then hope that the issue happens in Oculus Browser in Oculus Quest Pro.

The following diff, in the project where I'm experimenting with this, shows the change to the host.three.js file that makes the app work (search for "this._states.values()" for example):

015692de31d62d3cd9fb9c125f24f331d21d7b27..31071e142a1432fedc73758b3dd07f0b8a07ec10

That host.three.js file is the one I copied out of this repo after running npm run build.

After I made the chages seen here in this PR, I ran npm run build, then I copied packages/amazon-sumerian-hosts-three/dist/host.three.js into that autonomys repo to fix the app.

Submission Checklist

I confirm that I have...

I also manually tested core.lex.html using the start-core server, but that test is broken on mainline2.0 also with a 404 on a Lex URL. I suppose it has gone stale, and it doesn't really matter because both Babylon and Three tests/examples work.


This contribution is licensed under the original MIT-0 license of the repository. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.