You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							85 lines
						
					
					
						
							3.0 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							85 lines
						
					
					
						
							3.0 KiB
						
					
					
				
								#!/bin/bash
							 | 
						|
								
							 | 
						|
								# High-Performance Android Emulator Launch Script
							 | 
						|
								# Optimized for Linux systems with NVIDIA graphics cards
							 | 
						|
								# Author: Matthew Raymer
							 | 
						|
								
							 | 
						|
								echo "🚀 Launching Android Emulator with GPU Acceleration..."
							 | 
						|
								
							 | 
						|
								# Check if emulator command exists
							 | 
						|
								if ! command -v emulator &> /dev/null; then
							 | 
						|
								    echo "❌ Error: Android emulator not found!"
							 | 
						|
								    echo "Please install Android Studio and add emulator to PATH"
							 | 
						|
								    echo "export PATH=\$PATH:\$ANDROID_HOME/emulator"
							 | 
						|
								    exit 1
							 | 
						|
								fi
							 | 
						|
								
							 | 
						|
								# Check if AVD exists
							 | 
						|
								if ! emulator -list-avds | grep -q "TimeSafari_Emulator"; then
							 | 
						|
								    echo "❌ Error: TimeSafari_Emulator AVD not found!"
							 | 
						|
								    echo "Available AVDs:"
							 | 
						|
								    emulator -list-avds
							 | 
						|
								    echo ""
							 | 
						|
								    echo "Please create TimeSafari_Emulator AVD or modify this script"
							 | 
						|
								    exit 1
							 | 
						|
								fi
							 | 
						|
								
							 | 
						|
								# Check if NVIDIA drivers are available
							 | 
						|
								if ! ls /usr/share/vulkan/icd.d/nvidia_icd.json &> /dev/null; then
							 | 
						|
								    echo "⚠️  Warning: NVIDIA Vulkan ICD not found"
							 | 
						|
								    echo "GPU acceleration may not work optimally"
							 | 
						|
								    echo "Consider installing NVIDIA drivers with Vulkan support"
							 | 
						|
								fi
							 | 
						|
								
							 | 
						|
								echo "✅ Environment checks passed"
							 | 
						|
								echo "🎮 Starting emulator with GPU acceleration..."
							 | 
						|
								
							 | 
						|
								# Launch emulator with GPU acceleration, network fixes, and performance tuning
							 | 
						|
								QT_QPA_PLATFORM=xcb \
							 | 
						|
								__NV_PRIME_RENDER_OFFLOAD=1 \
							 | 
						|
								__GLX_VENDOR_LIBRARY_NAME=nvidia \
							 | 
						|
								__VK_LAYER_NV_optimus=NVIDIA_only \
							 | 
						|
								VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json \
							 | 
						|
								DRI_PRIME=1 \
							 | 
						|
								emulator -avd TimeSafari_Emulator \
							 | 
						|
								  -gpu host \
							 | 
						|
								  -feature Vulkan \
							 | 
						|
								  -accel on \
							 | 
						|
								  -cores 6 \
							 | 
						|
								  -memory 4096 \
							 | 
						|
								  -no-boot-anim \
							 | 
						|
								  -no-snapshot-load \
							 | 
						|
								  -dns-server 8.8.8.8,1.1.1.1 \
							 | 
						|
								  -feature -Bluetooth
							 | 
						|
								
							 | 
						|
								echo "🎯 Emulator launched with GPU acceleration!"
							 | 
						|
								echo ""
							 | 
						|
								echo "📋 Performance Features Enabled:"
							 | 
						|
								echo "  - Hardware GPU acceleration"
							 | 
						|
								echo "  - Vulkan graphics API support"
							 | 
						|
								echo "  - NVIDIA GPU offloading"
							 | 
						|
								echo "  - 6 CPU cores allocated"
							 | 
						|
								echo "  - 4GB RAM allocated"
							 | 
						|
								echo "  - Fast startup (no boot animation)"
							 | 
						|
								echo "  - Clean state (no snapshot loading)"
							 | 
						|
								echo "  - Fixed DNS servers (8.8.8.8, 1.1.1.1)"
							 | 
						|
								echo "  - Bluetooth disabled (prevents hangs)"
							 | 
						|
								echo ""
							 | 
						|
								echo "🔧 Troubleshooting:"
							 | 
						|
								echo "  - If emulator is slow, check NVIDIA drivers"
							 | 
						|
								echo "  - For Intel/AMD graphics, remove NVIDIA-specific variables"
							 | 
						|
								echo "  - Monitor GPU usage with: nvidia-smi"
							 | 
						|
								echo ""
							 | 
						|
								echo "🔍 GPU Binding Issues:"
							 | 
						|
								echo "  If OpenGL still binds to Intel iGPU instead of NVIDIA:"
							 | 
						|
								echo "  1. Check emulator banner for 'OpenGL Vendor=Google (NVIDIA)'"
							 | 
						|
								echo "  2. Try alternative GPU modes:"
							 | 
						|
								echo "     - Pure OpenGL: Remove -feature Vulkan flag"
							 | 
						|
								echo "     - ANGLE path: Use -gpu angle_indirect"
							 | 
						|
								echo "     - Mesa fallback: Use -gpu mesa"
							 | 
						|
								echo "  3. Verify dGPU usage: nvidia-smi dmon -s u"
							 | 
						|
								echo ""
							 | 
						|
								echo "📋 Performance Verification:"
							 | 
						|
								echo "  - Monitor GPU utilization: watch -n1 'nvidia-smi --query-compute-apps=pid,process_name,used_memory --format=csv,noheader | grep qemu'"
							 | 
						|
								echo "  - Check ADB connection: adb kill-server && adb start-server"
							 | 
						|
								echo "  - Clean snapshots: Delete ~/.android/avd/TimeSafari_Emulator.avd/snapshots/"
							 | 
						|
								
							 |