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
251}251}
252 252
253NetworkGeometry::NetworkGeometry(const QUrl& url) :253NetworkGeometry::NetworkGeometry(const QUrl& url) :
254 _modelRequest(url),
254 _modelReply(NULL),255 _modelReply(NULL),
255 _mappingReply(NULL)256 _mappingReply(NULL),
257 _attempts(0)
256{258{
257 if (!url.isValid()) {259 if (!url.isValid()) {
258 return;260 return;
259 }261 }
260 QNetworkRequest modelRequest(url);262 _modelRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
261 modelRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);263 makeModelRequest();
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()));
266 264
267 QUrl mappingURL = url;265 QUrl mappingURL = url;
268 QString path = url.path();266 QString path = url.path();
@@ -312,12 +310,30 @@ glm::vec4 NetworkGeometry::computeAverageColor() const { · 43 unmodified lines
312 return (totalTriangles == 0) ? glm::vec4(1.0f, 1.0f, 1.0f, 1.0f) : totalColor / totalTriangles;310 return (totalTriangles == 0) ? glm::vec4(1.0f, 1.0f, 1.0f, 1.0f) : totalColor / totalTriangles;
313}311}
314 312
313void 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
315void NetworkGeometry::handleModelReplyError() {320void NetworkGeometry::handleModelReplyError() {
316 qDebug() << _modelReply->errorString() << "\n";321 QDebug debug = qDebug() << _modelReply->errorString();
317 322
318 _modelReply->disconnect(this);323 _modelReply->disconnect(this);
319 _modelReply->deleteLater();324 _modelReply->deleteLater();
320 _modelReply = NULL;325 _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 }
321}337}
322 338
323void NetworkGeometry::handleMappingReplyError() {339void 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