Skip to content

Commit 957f717

Browse files
yaustarsteveny-sc
andauthored
Added retries to scene loading (playcanvas#3418)
Co-authored-by: Steven Yau <syau@snapchat.com>
1 parent 0afb685 commit 957f717

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

src/resources/hierarchy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class HierarchyHandler {
88
}
99

1010
load(url, callback) {
11-
SceneUtils.load(url, callback);
11+
SceneUtils.load(url, this.maxRetries, callback);
1212
}
1313

1414
open(url, data) {

src/resources/scene-settings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class SceneSettingsHandler {
77
}
88

99
load(url, callback) {
10-
SceneUtils.load(url, callback);
10+
SceneUtils.load(url, this.maxRetries, callback);
1111
}
1212

1313
open(url, data) {

src/resources/scene-utils.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ const SceneUtils = {
88
* @name SceneUtils.load
99
* @description Loads the scene JSON file from a URL.
1010
* @param {string} url - URL to scene JSON.
11+
* @param {number} maxRetries - Number of http load retry attempts.
1112
* @param {Function} callback - The callback to the JSON file is loaded.
1213
*/
13-
load: function (url, callback) {
14+
load: function (url, maxRetries, callback) {
1415
if (typeof url === 'string') {
1516
url = {
1617
load: url,
@@ -19,8 +20,8 @@ const SceneUtils = {
1920
}
2021

2122
http.get(url.load, {
22-
retry: this.maxRetries > 0,
23-
maxRetries: this.maxRetries
23+
retry: maxRetries > 0,
24+
maxRetries: maxRetries
2425
}, function (err, response) {
2526
if (!err) {
2627
callback(err, response);

src/resources/scene.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class SceneHandler {
1515
}
1616

1717
load(url, callback) {
18-
SceneUtils.load(url, callback);
18+
SceneUtils.load(url, this.maxRetries, callback);
1919
}
2020

2121
open(url, data) {

0 commit comments

Comments
 (0)