GPU debugging

parent 3bdf31e2
...@@ -664,7 +664,9 @@ class OverlayWebView(QWebEngineView): ...@@ -664,7 +664,9 @@ class OverlayWebView(QWebEngineView):
'QTWEBENGINE_CHROMIUM_FLAGS', 'QTWEBENGINE_CHROMIUM_FLAGS',
'QT_QPA_PLATFORM', 'QT_QPA_PLATFORM',
'DISPLAY', 'DISPLAY',
'XDG_SESSION_TYPE' 'XDG_SESSION_TYPE',
'QTWEBENGINE_DISABLE_SANDBOX',
'QTWEBENGINE_REMOTE_DEBUGGING'
] ]
logger.info("=== GPU Environment Check ===") logger.info("=== GPU Environment Check ===")
...@@ -672,15 +674,32 @@ class OverlayWebView(QWebEngineView): ...@@ -672,15 +674,32 @@ class OverlayWebView(QWebEngineView):
value = os.environ.get(var) value = os.environ.get(var)
logger.info(f"{var}: {value if value else '<not set>'}") logger.info(f"{var}: {value if value else '<not set>'}")
# Check for NVIDIA GPU # Check for NVIDIA GPU and processes
try: try:
import subprocess import subprocess
result = subprocess.run(['nvidia-smi', '--query-gpu=name,memory.total,memory.used', '--format=csv,noheader,nounits'], # Check GPU info
result = subprocess.run(['nvidia-smi', '--query-gpu=name,memory.total,memory.used,driver_version', '--format=csv,noheader,nounits'],
capture_output=True, text=True, timeout=5) capture_output=True, text=True, timeout=5)
if result.returncode == 0: if result.returncode == 0:
logger.info(f"NVIDIA GPU detected: {result.stdout.strip()}") gpu_info = result.stdout.strip().split(',')
logger.info(f"NVIDIA GPU detected: {gpu_info[0]}, Memory: {gpu_info[1]}/{gpu_info[2]}MB, Driver: {gpu_info[3]}")
else: else:
logger.warning("nvidia-smi not available or failed") logger.warning("nvidia-smi not available or failed")
# Check GPU processes specifically
proc_result = subprocess.run(['nvidia-smi', 'pmon'], capture_output=True, text=True, timeout=5)
if proc_result.returncode == 0:
lines = proc_result.stdout.strip().split('\n')
gpu_processes = [line for line in lines if line.strip() and not line.startswith('#')]
if gpu_processes:
logger.info(f"Active GPU processes: {len(gpu_processes)} found")
for proc in gpu_processes[:3]: # Log first 3 processes
logger.info(f"GPU Process: {proc}")
else:
logger.warning("NO GPU PROCESSES FOUND - This indicates GPU is not being utilized")
else:
logger.warning("Could not check GPU processes")
except Exception as e: except Exception as e:
logger.warning(f"Could not check NVIDIA GPU: {e}") logger.warning(f"Could not check NVIDIA GPU: {e}")
...@@ -695,7 +714,19 @@ class OverlayWebView(QWebEngineView): ...@@ -695,7 +714,19 @@ class OverlayWebView(QWebEngineView):
except Exception as e: except Exception as e:
logger.warning(f"Could not check OpenGL: {e}") logger.warning(f"Could not check OpenGL: {e}")
# Check Vulkan (Qt WebEngine can use Vulkan on some systems)
try:
result = subprocess.run(['vulkaninfo', '--summary'], capture_output=True, text=True, timeout=5)
if result.returncode == 0:
logger.info("Vulkan is available")
else:
logger.info("Vulkan not available or not configured")
except Exception as e:
logger.debug(f"Vulkan check failed: {e}")
logger.info(f"Mesa software rendering detection: {is_mesa}") logger.info(f"Mesa software rendering detection: {is_mesa}")
if is_mesa:
logger.warning("MESA SOFTWARE RENDERING DETECTED - GPU acceleration may be disabled")
# Set transparent background on the web page # Set transparent background on the web page
page = self.page() page = self.page()
...@@ -751,6 +782,7 @@ class OverlayWebView(QWebEngineView): ...@@ -751,6 +782,7 @@ class OverlayWebView(QWebEngineView):
# The javaScriptConsoleMessage signal connection was removed as it was failing # The javaScriptConsoleMessage signal connection was removed as it was failing
# Load default template # Load default template
logger.info("DEBUG: About to load default template in OverlayWebView.setup_web_view")
self.load_template(self.current_template) self.load_template(self.current_template)
# Show debug console if debug mode is enabled # Show debug console if debug mode is enabled
...@@ -759,6 +791,15 @@ class OverlayWebView(QWebEngineView): ...@@ -759,6 +791,15 @@ class OverlayWebView(QWebEngineView):
logger.info("DEBUG: Connecting loadFinished signal to _enable_debug_console") logger.info("DEBUG: Connecting loadFinished signal to _enable_debug_console")
self.page().loadFinished.connect(self._enable_debug_console) self.page().loadFinished.connect(self._enable_debug_console)
# Add overlay visibility monitoring
logger.info("DEBUG: Setting up overlay visibility monitoring")
QTimer.singleShot(1000, self._check_overlay_visibility)
QTimer.singleShot(5000, self._check_overlay_visibility)
QTimer.singleShot(10000, self._check_overlay_visibility)
# Check Qt WebEngine GPU acceleration status
QTimer.singleShot(2000, self._check_qt_webengine_gpu_status)
def _enable_debug_console(self, ok=None): def _enable_debug_console(self, ok=None):
"""Enable debug console and ensure JavaScript overrides are active""" """Enable debug console and ensure JavaScript overrides are active"""
try: try:
...@@ -895,7 +936,7 @@ class OverlayWebView(QWebEngineView): ...@@ -895,7 +936,7 @@ class OverlayWebView(QWebEngineView):
def load_template(self, template_name: str): def load_template(self, template_name: str):
"""Load a specific template file, prioritizing uploaded templates""" """Load a specific template file, prioritizing uploaded templates"""
try: try:
logger.debug(f"Loading overlay template: {template_name}") logger.info(f"=== LOADING OVERLAY TEMPLATE: {template_name} ===")
if self.debug_overlay: if self.debug_overlay:
logger.debug(f"GREEN SCREEN DEBUG: Starting template load - {template_name}") logger.debug(f"GREEN SCREEN DEBUG: Starting template load - {template_name}")
logger.debug(f"GREEN SCREEN DEBUG: Current page URL before load: {self.url().toString()}") logger.debug(f"GREEN SCREEN DEBUG: Current page URL before load: {self.url().toString()}")
...@@ -912,18 +953,23 @@ class OverlayWebView(QWebEngineView): ...@@ -912,18 +953,23 @@ class OverlayWebView(QWebEngineView):
if not template_name.endswith('.html'): if not template_name.endswith('.html'):
template_name += '.html' template_name += '.html'
logger.info(f"Template name resolved to: {template_name}")
# First try uploaded templates directory (user uploads take priority) # First try uploaded templates directory (user uploads take priority)
template_path = self.uploaded_templates_dir / template_name template_path = self.uploaded_templates_dir / template_name
template_source = "uploaded" template_source = "uploaded"
logger.info(f"Checking uploaded templates: {template_path} (exists: {template_path.exists()})")
# If not found in uploaded, try built-in templates # If not found in uploaded, try built-in templates
if not template_path.exists(): if not template_path.exists():
template_path = self.builtin_templates_dir / template_name template_path = self.builtin_templates_dir / template_name
template_source = "builtin" template_source = "builtin"
logger.info(f"Checking builtin templates: {template_path} (exists: {template_path.exists()})")
# If still not found, fallback to default.html in built-in templates # If still not found, fallback to default.html in built-in templates
if not template_path.exists(): if not template_path.exists():
default_template_path = self.builtin_templates_dir / "default.html" default_template_path = self.builtin_templates_dir / "default.html"
logger.info(f"Template not found, trying fallback: {default_template_path} (exists: {default_template_path.exists()})")
if default_template_path.exists(): if default_template_path.exists():
template_path = default_template_path template_path = default_template_path
template_name = "default.html" template_name = "default.html"
...@@ -936,6 +982,7 @@ class OverlayWebView(QWebEngineView): ...@@ -936,6 +982,7 @@ class OverlayWebView(QWebEngineView):
return return
if template_path and template_path.exists(): if template_path and template_path.exists():
logger.info(f"TEMPLATE FOUND: {template_path} (source: {template_source})")
if self.debug_overlay: if self.debug_overlay:
logger.debug(f"GREEN SCREEN DEBUG: About to load template file: {template_path}") logger.debug(f"GREEN SCREEN DEBUG: About to load template file: {template_path}")
logger.debug(f"GREEN SCREEN DEBUG: Template source: {template_source}") logger.debug(f"GREEN SCREEN DEBUG: Template source: {template_source}")
...@@ -953,6 +1000,7 @@ class OverlayWebView(QWebEngineView): ...@@ -953,6 +1000,7 @@ class OverlayWebView(QWebEngineView):
# Test if we can read the template file # Test if we can read the template file
with open(template_path, 'r', encoding='utf-8') as f: with open(template_path, 'r', encoding='utf-8') as f:
content = f.read() content = f.read()
logger.info(f"TEMPLATE CONTENT LENGTH: {len(content)} characters")
if len(content) == 0: if len(content) == 0:
logger.warning(f"Template file {template_path} is empty, using fallback") logger.warning(f"Template file {template_path} is empty, using fallback")
self._load_fallback_overlay() self._load_fallback_overlay()
...@@ -963,6 +1011,7 @@ class OverlayWebView(QWebEngineView): ...@@ -963,6 +1011,7 @@ class OverlayWebView(QWebEngineView):
self._load_fallback_overlay() self._load_fallback_overlay()
return return
logger.info(f"LOADING TEMPLATE INTO WEBENGINE: {template_path}")
self.load(QUrl.fromLocalFile(str(template_path))) self.load(QUrl.fromLocalFile(str(template_path)))
self.current_template = template_name self.current_template = template_name
...@@ -996,7 +1045,7 @@ class OverlayWebView(QWebEngineView): ...@@ -996,7 +1045,7 @@ class OverlayWebView(QWebEngineView):
if self.debug_overlay: if self.debug_overlay:
logger.debug(f"GREEN SCREEN DEBUG: Template load initiated - {template_path}") logger.debug(f"GREEN SCREEN DEBUG: Template load initiated - {template_path}")
logger.info(f"Loaded template: {template_path} (source: {template_source})") logger.info(f"=== TEMPLATE LOAD COMPLETED: {template_path} (source: {template_source}) ===")
else: else:
logger.error(f"No template found: {template_name}") logger.error(f"No template found: {template_name}")
# Load fallback minimal overlay # Load fallback minimal overlay
...@@ -1315,6 +1364,155 @@ class OverlayWebView(QWebEngineView): ...@@ -1315,6 +1364,155 @@ class OverlayWebView(QWebEngineView):
except Exception as e: except Exception as e:
logger.error(f"Failed to start GPU process monitoring: {e}") logger.error(f"Failed to start GPU process monitoring: {e}")
def _check_overlay_visibility(self):
"""Check overlay window visibility and positioning"""
try:
logger.info("=== OVERLAY VISIBILITY CHECK ===")
logger.info(f"Overlay window exists: {self.parent() is not None}")
if self.parent():
parent = self.parent()
logger.info(f"Parent window geometry: {parent.geometry()}")
logger.info(f"Parent window visible: {parent.isVisible()}")
logger.info(f"Parent window on top: {parent.windowFlags() & Qt.WindowType.WindowStaysOnTopHint}")
logger.info(f"Overlay WebView visible: {self.isVisible()}")
logger.info(f"Overlay WebView geometry: {self.geometry()}")
logger.info(f"Overlay WebView size: {self.size()}")
logger.info(f"Overlay WebView pos: {self.pos()}")
# Check WebEngine page status
page = self.page()
if page:
logger.info(f"WebEngine page URL: {page.url().toString()}")
logger.info(f"WebEngine page title: {page.title()}")
# Check if page has content
page.runJavaScript("""
console.log('OVERLAY VISIBILITY: Checking page content');
console.log('Body exists:', !!document.body);
if (document.body) {
console.log('Body innerHTML length:', document.body.innerHTML.length);
console.log('Body background:', window.getComputedStyle(document.body).background);
console.log('Body opacity:', window.getComputedStyle(document.body).opacity);
}
console.log('OVERLAY VISIBILITY: Page check complete');
""")
# Check GPU processes specifically for Qt WebEngine
try:
import subprocess
result = subprocess.run(['nvidia-smi', 'pmon'], capture_output=True, text=True, timeout=5)
if result.returncode == 0:
lines = result.stdout.strip().split('\n')
qt_processes = [line for line in lines if 'QtWebEngine' in line or 'python' in line.lower()]
if qt_processes:
logger.info(f"Qt WebEngine GPU processes found: {len(qt_processes)}")
for proc in qt_processes:
logger.info(f"GPU Process: {proc}")
else:
logger.warning("NO Qt WebEngine GPU processes found - overlay may not be using GPU acceleration")
else:
logger.warning("Could not check GPU processes for Qt WebEngine")
except Exception as e:
logger.debug(f"GPU process check failed: {e}")
logger.info("=== END OVERLAY VISIBILITY CHECK ===")
except Exception as e:
logger.error(f"Failed to check overlay visibility: {e}")
def _check_qt_webengine_gpu_status(self):
"""Check Qt WebEngine GPU acceleration status"""
try:
logger.info("=== QT WEBENGINE GPU ACCELERATION CHECK ===")
# Check Qt WebEngine version and GPU flags
from PyQt6.QtWebEngineCore import QWebEngineProfile
profile = self.page().profile()
logger.info(f"Qt WebEngine profile: {profile.storageName()}")
# Check if GPU acceleration is enabled via JavaScript
page = self.page()
if page:
page.runJavaScript("""
console.log('QT WEBENGINE GPU CHECK: Starting GPU acceleration test');
// Check WebGL support
const canvas = document.createElement('canvas');
const gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
if (gl) {
console.log('QT WEBENGINE GPU: WebGL is supported');
const debugInfo = gl.getExtension('WEBGL_debug_renderer_info');
if (debugInfo) {
const renderer = gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL);
const vendor = gl.getParameter(debugInfo.UNMASKED_VENDOR_WEBGL);
console.log('QT WEBENGINE GPU: Renderer - ' + renderer);
console.log('QT WEBENGINE GPU: Vendor - ' + vendor);
} else {
console.log('QT WEBENGINE GPU: Debug renderer info not available');
}
} else {
console.log('QT WEBENGINE GPU: WebGL is NOT supported - GPU acceleration disabled');
}
// Check for software rendering indicators
const isSoftware = navigator.userAgent.includes('Mesa') ||
document.body.style.backgroundColor.includes('rgba(0,0,0,0.01)');
console.log('QT WEBENGINE GPU: Software rendering detected: ' + isSoftware);
console.log('QT WEBENGINE GPU CHECK: Complete');
""")
# Check environment variables that affect GPU acceleration
import os
gpu_env_vars = [
'QTWEBENGINE_CHROMIUM_FLAGS',
'QT_QPA_PLATFORM',
'LIBGL_ALWAYS_SOFTWARE',
'MESA_GL_VERSION_OVERRIDE',
'QTWEBENGINE_DISABLE_GPU'
]
logger.info("Qt WebEngine GPU environment variables:")
for var in gpu_env_vars:
value = os.environ.get(var)
logger.info(f" {var}: {value if value else '<not set>'}")
# Check if GPU blacklist is active
try:
# Try to run a simple GPU test
page.runJavaScript("""
// Test GPU compositing
const testDiv = document.createElement('div');
testDiv.style.width = '100px';
testDiv.style.height = '100px';
testDiv.style.background = 'linear-gradient(45deg, red, blue)';
testDiv.style.position = 'absolute';
testDiv.style.top = '-200px'; // Off-screen
testDiv.id = 'gpu-test-element';
document.body.appendChild(testDiv);
// Check if transform3d is hardware accelerated
testDiv.style.transform = 'translate3d(0, 0, 0)';
const styles = window.getComputedStyle(testDiv);
const transform = styles.transform;
console.log('QT WEBENGINE GPU: 3D transform support: ' + (transform.includes('matrix') || transform.includes('translate3d')));
// Clean up
setTimeout(() => {
if (document.getElementById('gpu-test-element')) {
document.body.removeChild(testDiv);
}
}, 1000);
""")
except Exception as e:
logger.debug(f"GPU compositing test failed: {e}")
logger.info("=== END QT WEBENGINE GPU ACCELERATION CHECK ===")
except Exception as e:
logger.error(f"Failed to check Qt WebEngine GPU status: {e}")
# Removed _on_javaScript_console_message method as console capturing now uses WebChannel # Removed _on_javaScript_console_message method as console capturing now uses WebChannel
...@@ -1800,12 +1998,14 @@ class PlayerWindow(QMainWindow): ...@@ -1800,12 +1998,14 @@ class PlayerWindow(QMainWindow):
# THREADING FIXED: Re-enable overlay system with proper Qt main thread architecture # THREADING FIXED: Re-enable overlay system with proper Qt main thread architecture
# Create overlay as SEPARATE TOP-LEVEL WINDOW # Create overlay as SEPARATE TOP-LEVEL WINDOW
logger.info("=== CREATING OVERLAY WINDOW ===")
self.overlay_window = QWidget() self.overlay_window = QWidget()
self.overlay_window.setWindowFlags( self.overlay_window.setWindowFlags(
Qt.WindowType.FramelessWindowHint | Qt.WindowType.FramelessWindowHint |
Qt.WindowType.WindowStaysOnTopHint | Qt.WindowType.WindowStaysOnTopHint |
Qt.WindowType.Tool Qt.WindowType.Tool
) )
logger.info("Overlay window created with flags: Frameless, StaysOnTop, Tool")
# Mesa-specific transparency handling # Mesa-specific transparency handling
import os import os
...@@ -1816,12 +2016,12 @@ class PlayerWindow(QMainWindow): ...@@ -1816,12 +2016,12 @@ class PlayerWindow(QMainWindow):
# Mesa compatibility - use composition-based transparency # Mesa compatibility - use composition-based transparency
self.overlay_window.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, False) self.overlay_window.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, False)
self.overlay_window.setStyleSheet("background: rgba(0, 0, 0, 0.01);") self.overlay_window.setStyleSheet("background: rgba(0, 0, 0, 0.01);")
logger.debug("Mesa overlay window configured with composition transparency") logger.info("Mesa overlay window configured with composition transparency (WA_TranslucentBackground=False)")
else: else:
# Standard hardware transparency # Standard hardware transparency
self.overlay_window.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, True) self.overlay_window.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, True)
self.overlay_window.setStyleSheet("background: transparent;") self.overlay_window.setStyleSheet("background: transparent;")
logger.debug("Hardware overlay window configured with native transparency") logger.info("Hardware overlay window configured with native transparency (WA_TranslucentBackground=True)")
# Create overlay based on configuration - matching test_video_debug.py behavior # Create overlay based on configuration - matching test_video_debug.py behavior
if self.settings.use_native_overlay: if self.settings.use_native_overlay:
......
#!/bin/bash
# Remote debugging script for overlay/GPU issues on nvidia-tesla-470 system
echo "=== REMOTE DEBUGGING SCRIPT FOR OVERLAY/GPU ISSUES ==="
echo "System: $(uname -a)"
echo "Date: $(date)"
echo ""
echo "=== NVIDIA GPU STATUS ==="
nvidia-smi
echo ""
echo "=== GPU PROCESSES ==="
nvidia-smi pmon
echo ""
echo "=== OPENGL STATUS ==="
glxinfo | head -20
echo ""
echo "=== DIRECT RENDERING STATUS ==="
glxinfo | grep -i direct
echo ""
echo "=== VULKAN STATUS ==="
if command -v vulkaninfo &> /dev/null; then
vulkaninfo --summary
else
echo "vulkaninfo not available"
fi
echo ""
echo "=== ENVIRONMENT VARIABLES ==="
echo "DISPLAY: $DISPLAY"
echo "XDG_SESSION_TYPE: $XDG_SESSION_TYPE"
echo "QT_QPA_PLATFORM: $QT_QPA_PLATFORM"
echo "LIBGL_ALWAYS_SOFTWARE: $LIBGL_ALWAYS_SOFTWARE"
echo "MESA_GL_VERSION_OVERRIDE: $MESA_GL_VERSION_OVERRIDE"
echo ""
echo "=== RUNNING MBETTERCLIENT WITH DEBUG LOGGING ==="
echo "Please run the following command on your system:"
echo "./MbetterClient --debug --debug-overlay --debug-player --no-fullscreen"
echo ""
echo "This will:"
echo "- Enable debug logging"
echo "- Enable overlay debug mode"
echo "- Enable player debug mode"
echo "- Run in windowed mode for easier debugging"
echo ""
echo "Then check the logs for:"
echo "1. OVERLAY VISIBILITY CHECK messages"
echo "2. QT WEBENGINE GPU ACCELERATION CHECK messages"
echo "3. TEMPLATE LOADING messages"
echo "4. GPU process monitoring messages"
echo ""
echo "If overlay templates are not shown, look for:"
echo "- 'NO GPU PROCESSES FOUND' warnings"
echo "- Mesa software rendering detection"
echo "- Template loading failures"
echo "- Overlay window visibility issues"
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment