History

When we fail to download textures or geometry, retry after steadily increasing delays. Closes #1471.

Andrzej Kapolka committed 12 years ago

Commit 0694a7d1 parent 0f2aa6c4 files · +61 −18Browse files

Showing the changes to interface/src/renderer/GeometryCache.cpp (1 of 4 files). Show all

Unified · Split

interface/src/renderer/GeometryCache.cpp+24−8
@@ -251,18 +251,16 @@ QSharedPointer<NetworkGeometry> GeometryCache::getGeometry(const QUrl& url) { · 250 unmodified lines
251251 }
252252
253253 NetworkGeometry::NetworkGeometry(const QUrl& url) :
254+ _modelRequest(url),
254255 _modelReply(NULL),
255− _mappingReply(NULL)
256+ _mappingReply(NULL),
257+ _attempts(0)
256258 {
257259 if (!url.isValid()) {
258260 return;
259261 }
260− QNetworkRequest modelRequest(url);
261− modelRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
262− _modelReply = Application::getInstance()->getNetworkAccessManager()->get(modelRequest);
263−
264− connect(_modelReply, SIGNAL(downloadProgress(qint64,qint64)), SLOT(maybeReadModelWithMapping()));
265− connect(_modelReply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(handleModelReplyError()));
262+ _modelRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
263+ makeModelRequest();
266264
267265 QUrl mappingURL = url;
268266 QString path = url.path();
@@ -312,12 +310,30 @@ glm::vec4 NetworkGeometry::computeAverageColor() const { · 43 unmodified lines
312310 return (totalTriangles == 0) ? glm::vec4(1.0f, 1.0f, 1.0f, 1.0f) : totalColor / totalTriangles;
313311 }
314312
313+void NetworkGeometry::makeModelRequest() {
314+ _modelReply = Application::getInstance()->getNetworkAccessManager()->get(_modelRequest);
315+
316+ connect(_modelReply, SIGNAL(downloadProgress(qint64,qint64)), SLOT(maybeReadModelWithMapping()));
317+ connect(_modelReply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(handleModelReplyError()));
318+}
319+
315320 void NetworkGeometry::handleModelReplyError() {
316− qDebug() << _modelReply->errorString() << "\n";
321+ QDebug debug = qDebug() << _modelReply->errorString();
317322
318323 _modelReply->disconnect(this);
319324 _modelReply->deleteLater();
320325 _modelReply = NULL;
326+
327+ // retry with increasing delays
328+ const int MAX_ATTEMPTS = 8;
329+ const int BASE_DELAY_MS = 1000;
330+ if (++_attempts < MAX_ATTEMPTS) {
331+ QTimer::singleShot(BASE_DELAY_MS * (int)pow(2.0, _attempts), this, SLOT(makeModelRequest()));
332+ debug << " -- retrying...\n";
333+
334+ } else {
335+ debug << "\n";
336+ }
321337 }
322338
323339 void NetworkGeometry::handleMappingReplyError() {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t