Bug fix for blank webEntities during long sessions

In prolonged sessions _currentWebCount would reach MAX_CONCURRENT_WEB_VIEWS and prevent new webEntities from being properly created and initialized.

The _currentWebCount inside of RenderableWebEntityItem would become inflated when buildWebSurface is called without a currentContext.
The early return did not properly take this into account.  Instead we move the increment after the early return and right before the _webSurface is actually created.
This commit is contained in:
Anthony J. Thibault 2016-11-14 17:52:18 -08:00
parent 786d09795b
commit eb401c125a

View file

@ -69,8 +69,6 @@ bool RenderableWebEntityItem::buildWebSurface(QSharedPointer<EntityTreeRenderer>
qWarning() << "Too many concurrent web views to create new view";
return false;
}
qDebug() << "Building web surface";
QString javaScriptToInject;
QFile webChannelFile(":qtwebchannel/qwebchannel.js");
QFile createGlobalEventBridgeFile(PathUtils::resourcesPath() + "/html/createGlobalEventBridge.js");
@ -85,12 +83,15 @@ bool RenderableWebEntityItem::buildWebSurface(QSharedPointer<EntityTreeRenderer>
qCWarning(entitiesrenderer) << "unable to find qwebchannel.js or createGlobalEventBridge.js";
}
++_currentWebCount;
// Save the original GL context, because creating a QML surface will create a new context
QOpenGLContext * currentContext = QOpenGLContext::currentContext();
if (!currentContext) {
return false;
}
++_currentWebCount;
qDebug() << "Building web surface: " << getID() << ", #" << _currentWebCount << ", url = " << _sourceUrl;
QSurface * currentSurface = currentContext->surface();
auto deleter = [](OffscreenQmlSurface* webSurface) {
@ -356,6 +357,8 @@ void RenderableWebEntityItem::destroyWebSurface() {
QObject::disconnect(_hoverLeaveConnection);
_hoverLeaveConnection = QMetaObject::Connection();
_webSurface.reset();
qDebug() << "Delete web surface: " << getID() << ", #" << _currentWebCount << ", url = " << _sourceUrl;
}
}