-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scene View better handling for not loading 3D file (including CORS) #521
Conversation
Files changed:\nM src/Resources/Locales/cs.json M src/Resources/Locales/de.json M src/Resources/Locales/es.json M src/Resources/Locales/fr.json M src/Resources/Locales/hu.json M src/Resources/Locales/it.json M src/Resources/Locales/ja.json M src/Resources/Locales/ko.json M src/Resources/Locales/nl.json M src/Resources/Locales/pl.json M src/Resources/Locales/pt-pt.json M src/Resources/Locales/pt.json M src/Resources/Locales/ru.json M src/Resources/Locales/sv.json M src/Resources/Locales/tr.json M src/Resources/Locales/zh-Hans.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine, just 1 comment
src/Components/3DV/SceneView.tsx
Outdated
<div className={customStyles.errorMessage}> | ||
Error loading model. Try Ctrl-F5 | ||
{loadingError === 'common' && ( | ||
<div className={customStyles.commonErrorMessage}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason we dont want to use an illustration message for this as well? Probably a different illustartion than the CORS error, but might as well use that component since the styling is nice (vs just literal text)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, we can :) do you have in mind or I can ask Azima?
…ustration for generic type of error
…/iot-cardboard-js into iremay-scene-view-cors
Files changed:\nM src/Resources/Locales/cs.json M src/Resources/Locales/de.json M src/Resources/Locales/es.json M src/Resources/Locales/fr.json M src/Resources/Locales/hu.json M src/Resources/Locales/it.json M src/Resources/Locales/ja.json M src/Resources/Locales/ko.json M src/Resources/Locales/nl.json M src/Resources/Locales/pl.json M src/Resources/Locales/pt-pt.json M src/Resources/Locales/pt.json M src/Resources/Locales/ru.json M src/Resources/Locales/sv.json M src/Resources/Locales/tr.json M src/Resources/Locales/zh-Hans.json
…/iot-cardboard-js into iremay-scene-view-cors
Files changed:\nM src/Resources/Locales/cs.json M src/Resources/Locales/de.json M src/Resources/Locales/es.json M src/Resources/Locales/fr.json M src/Resources/Locales/hu.json M src/Resources/Locales/it.json M src/Resources/Locales/ja.json M src/Resources/Locales/ko.json M src/Resources/Locales/nl.json M src/Resources/Locales/pl.json M src/Resources/Locales/pt-pt.json M src/Resources/Locales/pt.json M src/Resources/Locales/ru.json M src/Resources/Locales/sv.json M src/Resources/Locales/tr.json M src/Resources/Locales/zh-Hans.json
…into iremay-scene-view-cors
…/iot-cardboard-js into iremay-scene-view-cors
src/Components/3DV/SceneView.tsx
Outdated
return dt.toISOString(); | ||
}) | ||
.catch((error) => { | ||
throw error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far as I can tell, throwing an error looks a risky change as it promotes the fetch for the modified date to the front line, and fails the load if there's a network error fetching the modified date. I have seen MANY instances where this call fails, but the model load succeeds. I originally had something similar, but backed off that as it failed too many loads.
Please ignore this comment if that is not true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also this line is technically wrong, but quite nice in practice.
mod = mod ? '?' + mod : '';
If we don't get modified date, we load without a query string which will never cache bust, so if you update the model, we will never load it if the previous version is in cache.
Now actually the getModifiedDate often fails and its a pain to have to keep reloading the model as most of the time, we haven't changed the model, so the behaviour is wrong, but IMHO desirable. If a customer meets this scenario, they can upload the new model with a new name and change their 3DScenesConfig (but better would be to fix their environment so the getModifiedDate works).
If we want to cache bust if the getModifiedDate fails, then this line could be
mod = '?' + mod || new Date().toIsoString();
but I don't like it as most of the time cache busting is not what the user wants, and it fills the cache with loads of copies of the same model (but we could enable the manifest check so it never gets cached at all). I've been meaning to discuss this on standup as I heard a rumour that one of our customers was hitting this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ptallettms, as you mentioned and we talked with Matt in dev chat, we have decided to move the CORS check logic to Babylon's loader method, but it seems they are swallowing the 403 CORS error in BABYLON.SceneLoader.Load and it is not either falling in its onError or wrapper try/catch blocks catch part. So I just contacted to Babylon team about the issue, hopefully they are going to help with that. Will keep you updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the line above engine.disableManifestCheck = true;
is causing the BABYLON.SceneLoader.Load method not surfacing the network error in its onError callback. I asked it to Babylon people and waiting for their reply if they are interconnected. @ptallettms why do we need disabling manifest check, was it for caching related?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ptallettms what is you final input on this mod related line? Is mod = '?' + mod || new Date().toIsoString();
better option now? I will keep it as it was originally and let me know if we want to change it, I can do after this PR, since the scope of this PR is handling CORS related error, not improving caching method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whilst technically incorrect, I'd leave it as it is as that is what the user probably intended.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for your reply!
Files changed:\nM src/Resources/Locales/cs.json M src/Resources/Locales/de.json M src/Resources/Locales/es.json M src/Resources/Locales/fr.json M src/Resources/Locales/hu.json M src/Resources/Locales/it.json M src/Resources/Locales/ja.json M src/Resources/Locales/ko.json M src/Resources/Locales/nl.json M src/Resources/Locales/pl.json M src/Resources/Locales/pt-pt.json M src/Resources/Locales/pt.json M src/Resources/Locales/ru.json M src/Resources/Locales/sv.json M src/Resources/Locales/tr.json M src/Resources/Locales/zh-Hans.json
Files changed:\nM src/Resources/Locales/cs.json M src/Resources/Locales/de.json M src/Resources/Locales/es.json M src/Resources/Locales/fr.json M src/Resources/Locales/hu.json M src/Resources/Locales/it.json M src/Resources/Locales/ja.json M src/Resources/Locales/ko.json M src/Resources/Locales/nl.json M src/Resources/Locales/pl.json M src/Resources/Locales/pt-pt.json M src/Resources/Locales/pt.json M src/Resources/Locales/ru.json M src/Resources/Locales/sv.json M src/Resources/Locales/tr.json M src/Resources/Locales/zh-Hans.json
Okay there has been a fix from Babylon team to expose the network error in the loader even caching is enabled @ptallettms @darsney: BabylonJS/Babylon.js#12647 whenever they merge, I will bump up the Babylon version in our package.json and move the CORS/network checking logic to the loader instead of getModifiedTime. |
UPDATE: Babylon team is going to publish the fix with Thursday's release: 5.11.0, then I am going to bump Babylon version and move the network error handling logic to loader instead: https://github.com/BabylonJS/Babylon.js/releases/tag/5.11.0 |
…row from getModifiedTime axios call beforehand
Files changed:\nM src/Resources/Locales/cs.json M src/Resources/Locales/de.json M src/Resources/Locales/es.json M src/Resources/Locales/fr.json M src/Resources/Locales/hu.json M src/Resources/Locales/it.json M src/Resources/Locales/ja.json M src/Resources/Locales/ko.json M src/Resources/Locales/nl.json M src/Resources/Locales/pl.json M src/Resources/Locales/pt-pt.json M src/Resources/Locales/pt.json M src/Resources/Locales/ru.json M src/Resources/Locales/sv.json M src/Resources/Locales/tr.json M src/Resources/Locales/zh-Hans.json
Files changed:\nM src/Resources/Locales/cs.json M src/Resources/Locales/de.json M src/Resources/Locales/es.json M src/Resources/Locales/fr.json M src/Resources/Locales/hu.json M src/Resources/Locales/it.json M src/Resources/Locales/ja.json M src/Resources/Locales/ko.json M src/Resources/Locales/nl.json M src/Resources/Locales/pl.json M src/Resources/Locales/pt-pt.json M src/Resources/Locales/pt.json M src/Resources/Locales/ru.json M src/Resources/Locales/sv.json M src/Resources/Locales/tr.json M src/Resources/Locales/zh-Hans.json
…into iremay-scene-view-cors
…/iot-cardboard-js into iremay-scene-view-cors
🎉 This PR is included in version 1.0.0-beta.262 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary of changes 🔍
TypeError: Failed to fetch
in its catch method without detailed response information. Also since the promise returned from fetch() won't reject on HTTP error status even if the response is an HTTP 404 or 500, it would be better to use axios.References:
Testing 🧪
Checklist ✔️