Only request debug data from VM thread if a debug tab is open

This commit is contained in:
Tim Mickel 2016-07-01 13:09:22 -04:00
parent a47a9a9b7e
commit 890be6611e

View file

@ -51,11 +51,14 @@ window.onload = function() {
} }
}; };
// Only request data from the VM thread if the appropriate tab is open.
window.exploreTabOpen = false;
var getPlaygroundData = function () { var getPlaygroundData = function () {
vm.getPlaygroundData(); vm.getPlaygroundData();
window.requestAnimationFrame(getPlaygroundData); if (window.exploreTabOpen) {
window.requestAnimationFrame(getPlaygroundData);
}
}; };
getPlaygroundData();
vm.on('playgroundData', function(data) { vm.on('playgroundData', function(data) {
updateThreadExplorer(data.threads); updateThreadExplorer(data.threads);
@ -101,18 +104,23 @@ window.onload = function() {
// Handlers to show different explorers. // Handlers to show different explorers.
document.getElementById('threadexplorer-link').addEventListener('click', document.getElementById('threadexplorer-link').addEventListener('click',
function () { function () {
window.exploreTabOpen = true;
getPlaygroundData();
tabBlockExplorer.style.display = 'none'; tabBlockExplorer.style.display = 'none';
tabRenderExplorer.style.display = 'none'; tabRenderExplorer.style.display = 'none';
tabThreadExplorer.style.display = 'block'; tabThreadExplorer.style.display = 'block';
}); });
document.getElementById('blockexplorer-link').addEventListener('click', document.getElementById('blockexplorer-link').addEventListener('click',
function () { function () {
window.exploreTabOpen = true;
getPlaygroundData();
tabBlockExplorer.style.display = 'block'; tabBlockExplorer.style.display = 'block';
tabRenderExplorer.style.display = 'none'; tabRenderExplorer.style.display = 'none';
tabThreadExplorer.style.display = 'none'; tabThreadExplorer.style.display = 'none';
}); });
document.getElementById('renderexplorer-link').addEventListener('click', document.getElementById('renderexplorer-link').addEventListener('click',
function () { function () {
window.exploreTabOpen = false;
tabBlockExplorer.style.display = 'none'; tabBlockExplorer.style.display = 'none';
tabRenderExplorer.style.display = 'block'; tabRenderExplorer.style.display = 'block';
tabThreadExplorer.style.display = 'none'; tabThreadExplorer.style.display = 'none';