diff --git a/README.md b/README.md index 045f19c..61b1374 100644 --- a/README.md +++ b/README.md @@ -311,6 +311,7 @@ const status = await DailyNotification.getDualScheduleStatus(); ### Quick Smoke Test For immediate validation of plugin functionality: + - **Android**: [Manual Smoke Test - Android](./docs/manual_smoke_test.md#android-platform-testing) - **iOS**: [Manual Smoke Test - iOS](./docs/manual_smoke_test.md#ios-platform-testing) - **Electron**: [Manual Smoke Test - Electron](./docs/manual_smoke_test.md#electron-platform-testing) @@ -319,6 +320,31 @@ For immediate validation of plugin functionality: Complete testing procedures: [docs/manual_smoke_test.md](./docs/manual_smoke_test.md) +### High-Performance Emulator Testing + +For optimal Android emulator performance on Linux systems with NVIDIA graphics: + +```bash +# Launch emulator with GPU acceleration +cd test-apps +./launch-emulator-gpu.sh +``` + +**Features:** +- Hardware GPU acceleration for smoother UI +- Vulkan graphics API support +- NVIDIA GPU offloading +- Fast startup and clean state +- Optimized for development workflow + +See [test-apps/SETUP_GUIDE.md](./test-apps/SETUP_GUIDE.md#advanced-emulator-launch-gpu-acceleration) for detailed configuration. + +**Troubleshooting GPU Issues:** + +- [EMULATOR_TROUBLESHOOTING.md](./test-apps/EMULATOR_TROUBLESHOOTING.md) - Comprehensive GPU binding solutions +- Alternative GPU modes: OpenGL, ANGLE, Mesa fallback +- Performance verification and optimization tips + ## Platform Requirements ### Android diff --git a/test-apps/EMULATOR_TROUBLESHOOTING.md b/test-apps/EMULATOR_TROUBLESHOOTING.md new file mode 100644 index 0000000..d410cba --- /dev/null +++ b/test-apps/EMULATOR_TROUBLESHOOTING.md @@ -0,0 +1,280 @@ +# Android Emulator GPU Troubleshooting Guide + +## Overview + +This guide helps resolve GPU binding issues when running Android emulators on Linux systems with NVIDIA graphics cards. The most common issue is when the emulator detects the NVIDIA GPU for Vulkan but still binds OpenGL rendering to the Intel iGPU. + +## Problem Diagnosis + +### GPU Binding Issues + +#### Symptoms +- Emulator runs but feels sluggish +- NVIDIA GPU shows low utilization in `nvidia-smi` +- Emulator banner shows Intel graphics in OpenGL renderer: + ``` + OpenGL Renderer=[Android Emulator OpenGL ES Translator (Mesa Intel(R) Graphics (RPL-S))] + ``` +- Vulkan detection works but OpenGL compositing uses Intel + +#### Root Cause +The emulator detects your NVIDIA GPU for Vulkan (`Selecting Vulkan device: NVIDIA GeForce RTX 4060...`) but the window/compositor path still binds to your Intel iGPU. Frames get decoded via gfxstream/Vulkan but final GL presentation rides the Intel driver. + +### Network Connectivity Issues + +#### Symptoms +- Play Services ANRs and timeouts +- "API failed to connect while resuming" errors +- `GmsClientSupervisor ... Timeout...` messages +- `Phenotype registration failed` errors +- NetworkMonitor shows hard failures: + - `ECONNREFUSED` on DNS lookups + - `UnknownHostException` for `www.google.com` / `connectivitycheck.gstatic.com` + - `[100 WIFI] validation failed` + +#### Root Cause +The emulator has no working internet/DNS connectivity, causing Google apps to stall and ANR. This is often caused by: +- DNS resolution failures +- VPN/killswitch blocking emulator traffic +- Firewall rules blocking outbound connections +- Corrupted network state from previous sessions + +## Solution Strategies + +### 1. Network Connectivity Fixes (Priority) + +If experiencing ANRs and Play Services failures, address network issues first: + +#### Quick Network Fix +```bash +cd test-apps +./launch-emulator-network-fix.sh +``` + +#### Verify Network Status +```bash +cd test-apps +./verify-emulator-network.sh +``` + +#### Manual Network Verification +```bash +# Check airplane mode +adb -e shell settings get global airplane_mode_on + +# Check network interfaces +adb -e shell ip addr; adb -e shell ip route + +# Test DNS resolution +adb -e shell ping -c1 8.8.8.8 +adb -e shell ping -c1 connectivitycheck.gstatic.com +``` + +#### Clear Play Services Cache +```bash +adb -e shell pm clear com.google.android.gms +adb -e shell pm clear com.android.vending +``` + +### 2. GPU Binding Solutions + +Use the enhanced launch script with all NVIDIA offloading variables: + +```bash +cd test-apps +./launch-emulator-gpu.sh +``` + +**What each variable does:** +- `__NV_PRIME_RENDER_OFFLOAD=1` + `__GLX_VENDOR_LIBRARY_NAME=nvidia`: Offload GL to NVIDIA +- `__VK_LAYER_NV_optimus=NVIDIA_only` + `VK_ICD_FILENAMES=...nvidia_icd.json`: Make Vulkan loader pick NVIDIA +- `DRI_PRIME=1`: Belt-and-suspenders in mixed Mesa/NVIDIA setups +- `QT_QPA_PLATFORM=xcb`: Avoids Wayland/Qt oddities +- `-no-snapshot-load`: Prevents flaky snapshots from different configs + +### 2. Alternative GPU Modes + +If the primary solution still binds to Intel, try these alternatives: + +#### Pure OpenGL Mode +```bash +cd test-apps +./launch-emulator-opengl.sh +``` +- Removes `-feature Vulkan` to avoid mixed VK+GL path +- Forces pure OpenGL rendering on NVIDIA +- Good when Vulkan+OpenGL mixed mode causes issues + +#### ANGLE Mode +```bash +cd test-apps +./launch-emulator-angle.sh +``` +- Uses ANGLE (Almost Native Graphics Layer Engine) +- Better NVIDIA compatibility on Linux +- More stable rendering pipeline + +#### Mesa Fallback +```bash +cd test-apps +./launch-emulator-mesa.sh +``` +- Software rendering as last resort +- Use only for stability testing +- More CPU intensive but very stable + +### 3. Manual Launch Commands + +If scripts don't work, use these manual commands: + +#### Enhanced GPU Launch +```bash +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 \ + -no-boot-anim \ + -no-snapshot-load +``` + +#### Pure OpenGL +```bash +QT_QPA_PLATFORM=xcb \ +__NV_PRIME_RENDER_OFFLOAD=1 \ +__GLX_VENDOR_LIBRARY_NAME=nvidia \ +DRI_PRIME=1 \ +emulator -avd TimeSafari_Emulator \ + -gpu host \ + -accel on \ + -no-boot-anim +``` + +#### ANGLE Mode +```bash +QT_QPA_PLATFORM=xcb \ +__NV_PRIME_RENDER_OFFLOAD=1 \ +__GLX_VENDOR_LIBRARY_NAME=nvidia \ +DRI_PRIME=1 \ +emulator -avd TimeSafari_Emulator \ + -gpu angle_indirect \ + -accel on \ + -no-boot-anim +``` + +## Verification + +### Check GPU Binding +After launching, check the emulator banner for: +- ✅ **Good**: `OpenGL Vendor=Google (NVIDIA)` or GL translator running atop NVIDIA +- ❌ **Bad**: `(Mesa Intel)` or Intel graphics in renderer + +### Monitor GPU Usage +```bash +# Real-time GPU utilization +nvidia-smi dmon -s u + +# Check emulator process specifically +watch -n1 "nvidia-smi --query-compute-apps=pid,process_name,used_memory --format=csv,noheader | grep qemu" +``` + +You should see non-zero GPU utilization/memory for the emulator process. + +## Additional Optimizations + +### Clean Snapshots +Snapshots made with different configs can cause issues: +```bash +# Delete snapshots for clean state +rm -rf ~/.android/avd/TimeSafari_Emulator.avd/snapshots/ +``` + +### Fix ADB Issues +"Device offline" after boot is common with snapshots: +```bash +adb kill-server && adb start-server +adb -e wait-for-device +``` + +### Disable Unnecessary Features +Save CPU, reduce log spam, and prevent hangs: +```bash +emulator -avd TimeSafari_Emulator \ + -gpu host -accel on -no-boot-anim \ + -feature -Bluetooth -camera-back none -camera-front none -no-audio +``` + +**Key Benefits:** +- `-feature -Bluetooth`: Prevents Bluetooth-related hangs and ANRs +- `-camera-back none -camera-front none`: Disables camera hardware +- `-no-audio`: Disables audio system (saves resources) + +### CPU/RAM Configuration +Keep your existing settings: +```bash +emulator -avd TimeSafari_Emulator \ + -cores 6 -memory 4096 \ + -gpu host -accel on -no-boot-anim +``` + +## Troubleshooting Checklist + +### Before Launch +- [ ] NVIDIA drivers installed and working +- [ ] Vulkan ICD file exists: `/usr/share/vulkan/icd.d/nvidia_icd.json` +- [ ] AVD exists and is properly configured +- [ ] Android SDK and emulator in PATH + +### After Launch +- [ ] Check emulator banner for correct GPU binding +- [ ] Monitor `nvidia-smi` for GPU utilization +- [ ] Verify ADB connection with `adb devices` +- [ ] Test app installation and functionality + +### If Still Having Issues +- [ ] Try different GPU modes (OpenGL, ANGLE, Mesa) +- [ ] Clean snapshots and restart +- [ ] Check system logs for GPU errors +- [ ] Verify NVIDIA driver compatibility +- [ ] Consider software rendering for stability testing + +## Performance Expectations + +### Hardware Acceleration (NVIDIA) +- **GPU Utilization**: 20-60% during normal use +- **Memory Usage**: 500MB-2GB GPU memory +- **UI Responsiveness**: Smooth, 60fps target +- **Startup Time**: 30-60 seconds + +### Software Rendering (Mesa) +- **CPU Usage**: 50-80% on all cores +- **Memory Usage**: 1-4GB system RAM +- **UI Responsiveness**: Slower, 30fps typical +- **Startup Time**: 60-120 seconds + +## System Requirements + +### Minimum +- **CPU**: 4 cores, 2.5GHz+ +- **RAM**: 8GB system, 4GB for emulator +- **GPU**: Any with OpenGL 3.0+ support +- **Storage**: 10GB free space + +### Recommended +- **CPU**: 6+ cores, 3.0GHz+ +- **RAM**: 16GB system, 6GB for emulator +- **GPU**: NVIDIA GTX 1060+ or equivalent +- **Storage**: 20GB free space, SSD preferred + +## Support + +If you continue experiencing issues: +1. Check the [Android Emulator documentation](https://developer.android.com/studio/run/emulator) +2. Review [NVIDIA Linux driver documentation](https://docs.nvidia.com/driver/) +3. Test with different AVD configurations +4. Consider using physical Android devices for testing diff --git a/test-apps/README.md b/test-apps/README.md index e6dd7ca..4113885 100644 --- a/test-apps/README.md +++ b/test-apps/README.md @@ -190,6 +190,53 @@ npx cap open android # Open in Android Studio npx cap run android # Run on device/emulator ``` +#### High-Performance Emulator Launch (Linux + NVIDIA) + +For optimal GPU acceleration on Linux systems: + +```bash +# Launch with GPU acceleration and performance optimizations +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 \ + -no-boot-anim \ + -no-snapshot-load +``` + +**Benefits:** +- Hardware GPU acceleration for smoother UI +- Vulkan graphics API support +- Faster startup (no boot animation) +- Clean state (no snapshot loading) +- Optimized for NVIDIA graphics cards + +#### Alternative GPU Modes + +If you experience GPU binding issues, try these alternatives: + +```bash +# Pure OpenGL mode (no Vulkan) +./launch-emulator-opengl.sh + +# ANGLE mode (better NVIDIA compatibility) +./launch-emulator-angle.sh + +# Mesa fallback (software rendering) +./launch-emulator-mesa.sh +``` + +**Troubleshooting:** +- See [EMULATOR_TROUBLESHOOTING.md](./EMULATOR_TROUBLESHOOTING.md) for detailed GPU binding solutions +- Check emulator banner for correct GPU binding +- Monitor GPU usage with `nvidia-smi dmon -s u` + ### iOS ```bash cd ios-test diff --git a/test-apps/SETUP_GUIDE.md b/test-apps/SETUP_GUIDE.md index 3bc52ca..e311bfa 100644 --- a/test-apps/SETUP_GUIDE.md +++ b/test-apps/SETUP_GUIDE.md @@ -194,7 +194,73 @@ npx cap open android npx cap run android ``` +#### Advanced Emulator Launch (GPU Acceleration) + +For optimal performance on Linux systems with NVIDIA graphics: + +```bash +# Launch emulator with GPU acceleration 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 +``` + +**Environment Variables Explained:** + +- `QT_QPA_PLATFORM=xcb`: Use X11 backend for Qt applications +- `__NV_PRIME_RENDER_OFFLOAD=1`: Enable NVIDIA GPU offloading +- `__GLX_VENDOR_LIBRARY_NAME=nvidia`: Use NVIDIA OpenGL library +- `__VK_LAYER_NV_optimus=NVIDIA_only`: Force NVIDIA Vulkan layer +- `VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json`: Specify NVIDIA Vulkan driver +- `DRI_PRIME=1`: Enable DRI Prime for GPU selection + +**Emulator Flags Explained:** + +- `-gpu host`: Use host GPU for hardware acceleration +- `-feature Vulkan`: Enable Vulkan graphics API support +- `-accel on`: Enable hardware acceleration +- `-cores 6`: Allocate 6 CPU cores to emulator +- `-memory 4096`: Allocate 4GB RAM to emulator +- `-no-boot-anim`: Skip boot animation for faster startup +- `-no-snapshot-load`: Don't load snapshots for clean state +- `-dns-server 8.8.8.8,1.1.1.1`: Use explicit DNS servers +- `-feature -Bluetooth`: Disable Bluetooth to prevent hangs + +#### Alternative GPU Modes + +If you experience GPU binding issues (OpenGL using Intel iGPU instead of NVIDIA), try these alternative launch scripts: + +```bash +# Pure OpenGL mode (no Vulkan) +./launch-emulator-opengl.sh + +# ANGLE mode (better NVIDIA compatibility) +./launch-emulator-angle.sh + +# Mesa fallback (software rendering) +./launch-emulator-mesa.sh +``` + +**Troubleshooting GPU Issues:** + +- Check emulator banner for `OpenGL Vendor=Google (NVIDIA)` +- Monitor GPU usage: `nvidia-smi dmon -s u` +- See [EMULATOR_TROUBLESHOOTING.md](./EMULATOR_TROUBLESHOOTING.md) for detailed solutions + ### iOS + ```bash cd test-apps/ios-test @@ -209,6 +275,7 @@ npx cap run ios ``` ### Electron + ```bash cd test-apps/electron-test @@ -225,6 +292,7 @@ npm run electron ## Testing Workflow ### 1. Web Testing (Recommended First) + ```bash # Test each platform's web version first cd test-apps/android-test && npm run dev @@ -233,6 +301,7 @@ cd test-apps/electron-test && npm start ``` ### 2. Native Testing + ```bash # After web testing succeeds, test native platforms cd test-apps/android-test && npx cap run android @@ -240,6 +309,7 @@ cd test-apps/ios-test && npx cap run ios ``` ### 3. Integration Testing + - Test plugin configuration - Test notification scheduling - Test platform-specific features @@ -249,12 +319,14 @@ cd test-apps/ios-test && npx cap run ios ## Troubleshooting Checklist ### General Issues + - [ ] Node.js 18+ installed - [ ] npm working correctly - [ ] Capacitor CLI installed globally - [ ] Dependencies installed (`npm install`) ### Android Issues + - [ ] Android Studio installed - [ ] Android SDK configured - [ ] `ANDROID_HOME` environment variable set @@ -262,12 +334,14 @@ cd test-apps/ios-test && npx cap run ios - [ ] Android platform added (`npx cap add android`) ### iOS Issues + - [ ] Xcode installed (macOS only) - [ ] Xcode Command Line Tools installed - [ ] iOS Simulator available - [ ] iOS platform added (`npx cap add ios`) ### Electron Issues + - [ ] Node.js working correctly - [ ] Dependencies installed - [ ] Web assets built (`npm run build-web`) @@ -275,16 +349,19 @@ cd test-apps/ios-test && npx cap run ios ## Development Tips ### Web Development + - Use `npm run dev` for hot reloading - Test plugin APIs in browser console - Use browser dev tools for debugging ### Native Development + - Use `npx cap sync` after making changes - Check native logs for detailed errors - Test on both physical devices and simulators ### Debugging + - Check console logs for errors - Use `npx cap doctor` to diagnose issues - Verify platform-specific requirements diff --git a/test-apps/launch-emulator-angle.sh b/test-apps/launch-emulator-angle.sh new file mode 100755 index 0000000..706d4ca --- /dev/null +++ b/test-apps/launch-emulator-angle.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +# Android Emulator Launch Script - ANGLE Mode +# Uses ANGLE (Almost Native Graphics Layer Engine) for better NVIDIA compatibility +# Alternative to host GPU mode when experiencing binding issues +# Author: Matthew Raymer + +echo "🚀 Launching Android Emulator - ANGLE Mode..." + +# 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" + 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 + exit 1 +fi + +echo "✅ Environment checks passed" +echo "🎮 Starting emulator with ANGLE rendering..." + +# Launch emulator with ANGLE and performance tuning +QT_QPA_PLATFORM=xcb \ +__NV_PRIME_RENDER_OFFLOAD=1 \ +__GLX_VENDOR_LIBRARY_NAME=nvidia \ +DRI_PRIME=1 \ +emulator -avd TimeSafari_Emulator \ + -gpu angle_indirect \ + -accel on \ + -cores 6 \ + -memory 4096 \ + -no-boot-anim \ + -no-snapshot-load \ + -feature -Bluetooth + +echo "🎯 Emulator launched with ANGLE rendering!" +echo "" +echo "📋 Configuration:" +echo " - ANGLE indirect rendering" +echo " - NVIDIA GPU offloading" +echo " - 6 CPU cores allocated" +echo " - 4GB RAM allocated" +echo " - Hardware acceleration enabled" +echo " - Fast startup (no boot animation)" +echo " - Clean state (no snapshot loading)" +echo " - Bluetooth disabled (prevents hangs)" +echo "" +echo "🔍 Benefits:" +echo " - Better NVIDIA compatibility on Linux" +echo " - Avoids mixed Vulkan+OpenGL binding issues" +echo " - More stable rendering pipeline" +echo " - Good fallback when host GPU mode fails" diff --git a/test-apps/launch-emulator-gpu.sh b/test-apps/launch-emulator-gpu.sh new file mode 100755 index 0000000..9649461 --- /dev/null +++ b/test-apps/launch-emulator-gpu.sh @@ -0,0 +1,85 @@ +#!/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/" diff --git a/test-apps/launch-emulator-help.sh b/test-apps/launch-emulator-help.sh new file mode 100755 index 0000000..b5aa6e6 --- /dev/null +++ b/test-apps/launch-emulator-help.sh @@ -0,0 +1,106 @@ +#!/bin/bash + +# Android Emulator Launch Options Helper +# Lists all available launch scripts and their purposes +# Author: Matthew Raymer + +echo "🚀 Android Emulator Launch Options" +echo "==================================" +echo "" + +echo "📋 Available Launch Scripts:" +echo "" + +echo "1. 🎮 GPU Accelerated (Recommended)" +echo " ./launch-emulator-gpu.sh" +echo " - Full NVIDIA GPU acceleration with Vulkan" +echo " - Best performance for development" +echo " - Use when GPU binding works correctly" +echo "" + +echo "2. 🔧 Pure OpenGL Mode" +echo " ./launch-emulator-opengl.sh" +echo " - Pure OpenGL rendering (no Vulkan)" +echo " - Use when Vulkan+OpenGL mixed mode binds to Intel iGPU" +echo " - Good fallback for GPU binding issues" +echo "" + +echo "3. ⚡ ANGLE Mode" +echo " ./launch-emulator-angle.sh" +echo " - ANGLE (Almost Native Graphics Layer Engine)" +echo " - Better NVIDIA compatibility on Linux" +echo " - More stable rendering pipeline" +echo "" + +echo "4. 🛡️ Mesa Fallback" +echo " ./launch-emulator-mesa.sh" +echo " - Software rendering as last resort" +echo " - Use for stability testing" +echo " - More CPU intensive but very stable" +echo "" + +echo "5. 🌐 Network Fix Mode" +echo " ./launch-emulator-network-fix.sh" +echo " - Fixes DNS/network connectivity issues" +echo " - Resolves Play Services ANRs and timeouts" +echo " - Clean state with explicit DNS servers" +echo "" + +echo "6. 🔍 Network Verification" +echo " ./verify-emulator-network.sh" +echo " - Diagnoses network connectivity problems" +echo " - Tests DNS resolution and internet access" +echo " - Identifies root cause of ANRs" +echo "" + +echo "7. ⚡ Maximum Performance Mode" +echo " ./launch-emulator-max-performance.sh" +echo " - All performance optimizations enabled" +echo " - 8 CPU cores, 6GB RAM allocated" +echo " - Disabled unnecessary features" +echo " - Use only on high-end systems (16GB+ RAM)" +echo "" + +echo "🔍 Troubleshooting:" +echo "" + +echo "If experiencing ANRs and Play Services failures:" +echo "1. Run network verification: ./verify-emulator-network.sh" +echo "2. Try network fix mode: ./launch-emulator-network-fix.sh" +echo "3. Clear Play Services cache if needed" +echo "4. Check VPN/firewall settings on host" +echo "" + +echo "If emulator feels sluggish or GPU utilization is low:" +echo "1. Check emulator banner for 'OpenGL Vendor=Google (NVIDIA)'" +echo "2. Monitor GPU usage: nvidia-smi dmon -s u" +echo "3. Try different GPU modes in order: GPU → OpenGL → ANGLE → Mesa" +echo "4. See EMULATOR_TROUBLESHOOTING.md for detailed solutions" +echo "" + +echo "📊 Performance Expectations:" +echo "" +echo "Hardware Acceleration (NVIDIA):" +echo " - GPU Utilization: 20-60%" +echo " - UI Responsiveness: Smooth, 60fps" +echo " - Startup Time: 30-60 seconds" +echo "" +echo "Software Rendering (Mesa):" +echo " - CPU Usage: 50-80%" +echo " - UI Responsiveness: Slower, 30fps" +echo " - Startup Time: 60-120 seconds" +echo "" + +echo "📚 Documentation:" +echo " - SETUP_GUIDE.md - Complete setup instructions" +echo " - EMULATOR_TROUBLESHOOTING.md - GPU binding solutions" +echo " - README.md - Project overview and quick start" +echo "" + +echo "🎯 Quick Start:" +echo " 1. If ANRs/Play Services issues: ./verify-emulator-network.sh" +echo " 2. If network issues: ./launch-emulator-network-fix.sh" +echo " 3. For GPU issues: ./launch-emulator-gpu.sh" +echo " 4. If GPU binding issues: ./launch-emulator-opengl.sh" +echo " 5. For maximum performance: ./launch-emulator-max-performance.sh" +echo " 6. Last resort: ./launch-emulator-mesa.sh" diff --git a/test-apps/launch-emulator-max-performance.sh b/test-apps/launch-emulator-max-performance.sh new file mode 100755 index 0000000..8e184e9 --- /dev/null +++ b/test-apps/launch-emulator-max-performance.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +# Android Emulator Launch Script - High Performance Mode +# Maximum performance with all optimizations enabled +# Author: Matthew Raymer + +echo "🚀 Launching Android Emulator - High Performance Mode..." + +# 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" + 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 + 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" +fi + +echo "✅ Environment checks passed" +echo "🎮 Starting emulator with maximum performance..." + +# Launch emulator with all performance optimizations +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 8 \ + -memory 6144 \ + -no-boot-anim \ + -no-snapshot-load \ + -dns-server 8.8.8.8,1.1.1.1 \ + -feature -Bluetooth \ + -camera-back none \ + -camera-front none \ + -no-audio + +echo "🎯 Emulator launched with maximum performance!" +echo "" +echo "📋 High Performance Features:" +echo " - Hardware GPU acceleration with Vulkan" +echo " - NVIDIA GPU offloading" +echo " - 8 CPU cores allocated (maximum)" +echo " - 6GB RAM allocated (high memory)" +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 " - Disabled unnecessary features:" +echo " - Bluetooth disabled" +echo " - Cameras disabled" +echo " - Audio disabled" +echo "" +echo "🔍 Performance Monitoring:" +echo " - GPU usage: nvidia-smi dmon -s u" +echo " - CPU usage: htop" +echo " - Memory usage: free -h" +echo "" +echo "⚠️ Note: This configuration uses maximum resources" +echo " - Ensure your system has sufficient RAM (16GB+ recommended)" +echo " - Monitor system performance during use" +echo " - Adjust -cores and -memory if system becomes unresponsive" diff --git a/test-apps/launch-emulator-mesa.sh b/test-apps/launch-emulator-mesa.sh new file mode 100755 index 0000000..1318685 --- /dev/null +++ b/test-apps/launch-emulator-mesa.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +# Android Emulator Launch Script - Mesa Fallback Mode +# Uses Mesa software rendering as last resort for stability +# Use when hardware acceleration causes issues +# Author: Matthew Raymer + +echo "🚀 Launching Android Emulator - Mesa Fallback Mode..." + +# 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" + 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 + exit 1 +fi + +echo "✅ Environment checks passed" +echo "🎮 Starting emulator with Mesa software rendering..." + +# Launch emulator with Mesa software rendering +emulator -avd TimeSafari_Emulator \ + -gpu mesa \ + -no-boot-anim \ + -no-snapshot-load \ + -feature -Bluetooth + +echo "🎯 Emulator launched with Mesa software rendering!" +echo "" +echo "📋 Configuration:" +echo " - Mesa software rendering" +echo " - No hardware acceleration" +echo " - Fast startup (no boot animation)" +echo " - Clean state (no snapshot loading)" +echo " - Bluetooth disabled (prevents hangs)" +echo "" +echo "⚠️ Performance Notes:" +echo " - Slower than hardware acceleration" +echo " - More CPU intensive" +echo " - Use only for stability testing" +echo " - Good for debugging GPU issues" +echo "" +echo "🔄 To return to hardware acceleration:" +echo " - Use ./launch-emulator-gpu.sh for NVIDIA GPU" +echo " - Use ./launch-emulator-opengl.sh for Pure OpenGL" +echo " - Use ./launch-emulator-angle.sh for ANGLE mode" diff --git a/test-apps/launch-emulator-network-fix.sh b/test-apps/launch-emulator-network-fix.sh new file mode 100755 index 0000000..cb2c3d5 --- /dev/null +++ b/test-apps/launch-emulator-network-fix.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +# Android Emulator Launch Script - Network Fix Mode +# Addresses DNS/network connectivity issues that cause ANRs and Play Services failures +# Author: Matthew Raymer + +echo "🚀 Launching Android Emulator - Network Fix Mode..." + +# 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" + 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 + exit 1 +fi + +echo "✅ Environment checks passed" +echo "🌐 Starting emulator with network fixes..." + +# Launch emulator with network fixes, performance tuning, and clean state +QT_QPA_PLATFORM=xcb \ +emulator -avd TimeSafari_Emulator \ + -gpu host \ + -accel on \ + -cores 6 \ + -memory 4096 \ + -no-boot-anim \ + -no-snapshot-load \ + -wipe-data \ + -dns-server 8.8.8.8,1.1.1.1 \ + -feature -Bluetooth + +echo "🎯 Emulator launched with network fixes!" +echo "" +echo "📋 Network Fixes Applied:" +echo " - Explicit DNS servers (8.8.8.8, 1.1.1.1)" +echo " - Clean state (wipe-data)" +echo " - No snapshot loading" +echo " - 6 CPU cores allocated" +echo " - 4GB RAM allocated" +echo " - Fast startup (no boot animation)" +echo " - Bluetooth disabled (prevents hangs)" +echo "" +echo "🔍 Network Verification Commands:" +echo " # Check airplane mode" +echo " adb -e shell settings get global airplane_mode_on" +echo "" +echo " # Check network interfaces" +echo " adb -e shell ip addr; adb -e shell ip route" +echo "" +echo " # Test DNS resolution" +echo " adb -e shell ping -c1 8.8.8.8" +echo " adb -e shell ping -c1 connectivitycheck.gstatic.com" +echo "" +echo "⚠️ Note: This will wipe emulator data for clean network state" diff --git a/test-apps/launch-emulator-opengl.sh b/test-apps/launch-emulator-opengl.sh new file mode 100755 index 0000000..fd07252 --- /dev/null +++ b/test-apps/launch-emulator-opengl.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +# Android Emulator Launch Script - Pure OpenGL Mode +# Forces OpenGL rendering on NVIDIA GPU (no Vulkan) +# Use when Vulkan+OpenGL mixed mode binds to Intel iGPU +# Author: Matthew Raymer + +echo "🚀 Launching Android Emulator - Pure OpenGL Mode..." + +# 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" + 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 + exit 1 +fi + +echo "✅ Environment checks passed" +echo "🎮 Starting emulator with Pure OpenGL rendering..." + +# Launch emulator with Pure OpenGL and performance tuning +QT_QPA_PLATFORM=xcb \ +__NV_PRIME_RENDER_OFFLOAD=1 \ +__GLX_VENDOR_LIBRARY_NAME=nvidia \ +DRI_PRIME=1 \ +emulator -avd TimeSafari_Emulator \ + -gpu host \ + -accel on \ + -cores 6 \ + -memory 4096 \ + -no-boot-anim \ + -no-snapshot-load \ + -feature -Bluetooth + +echo "🎯 Emulator launched with Pure OpenGL rendering!" +echo "" +echo "📋 Configuration:" +echo " - Pure OpenGL rendering (no Vulkan)" +echo " - NVIDIA GPU offloading" +echo " - 6 CPU cores allocated" +echo " - 4GB RAM allocated" +echo " - Hardware acceleration enabled" +echo " - Fast startup (no boot animation)" +echo " - Clean state (no snapshot loading)" +echo " - Bluetooth disabled (prevents hangs)" +echo "" +echo "🔍 Verification:" +echo " - Check banner for 'OpenGL Vendor=Google (NVIDIA)'" +echo " - Monitor GPU: nvidia-smi dmon -s u" +echo " - Should avoid Intel iGPU binding issues" diff --git a/test-apps/verify-emulator-network.sh b/test-apps/verify-emulator-network.sh new file mode 100755 index 0000000..e2751fd --- /dev/null +++ b/test-apps/verify-emulator-network.sh @@ -0,0 +1,107 @@ +#!/bin/bash + +# Android Emulator Network Verification Script +# Diagnoses network connectivity issues that cause ANRs and Play Services failures +# Author: Matthew Raymer + +echo "🔍 Android Emulator Network Verification" +echo "========================================" +echo "" + +# Check if emulator is running +if ! adb devices | grep -q "emulator.*device"; then + echo "❌ Error: No emulator detected!" + echo "Please start an emulator first" + exit 1 +fi + +echo "✅ Emulator detected" +echo "" + +echo "📋 Network Diagnostics:" +echo "" + +echo "1. 🔧 ADB Connection Status:" +adb devices +echo "" + +echo "2. ✈️ Airplane Mode Status:" +AIRPLANE_MODE=$(adb -e shell settings get global airplane_mode_on 2>/dev/null) +if [ "$AIRPLANE_MODE" = "1" ]; then + echo " ❌ Airplane mode is ON - this will block network access" + echo " 💡 Fix: adb -e shell settings put global airplane_mode_on 0" +else + echo " ✅ Airplane mode is OFF" +fi +echo "" + +echo "3. 🌐 Network Interfaces:" +echo " Network interfaces:" +adb -e shell ip addr | grep -E "(inet |UP|DOWN)" | head -10 +echo "" +echo " Routing table:" +adb -e shell ip route | head -5 +echo "" + +echo "4. 🏓 DNS Resolution Tests:" +echo " Testing Google DNS (8.8.8.8):" +if adb -e shell ping -c1 8.8.8.8 >/dev/null 2>&1; then + echo " ✅ Google DNS reachable" +else + echo " ❌ Google DNS unreachable - host/VPN/firewall blocking" +fi + +echo " Testing connectivity check (connectivitycheck.gstatic.com):" +if adb -e shell ping -c1 connectivitycheck.gstatic.com >/dev/null 2>&1; then + echo " ✅ Hostname resolution working" +else + echo " ❌ Hostname resolution failed - DNS issue" +fi +echo "" + +echo "5. 🔍 Play Services Status:" +echo " Google Play Services:" +adb -e shell dumpsys package com.google.android.gms | grep -E "(versionName|enabled)" | head -2 +echo "" + +echo "6. 📊 Network Monitor Logs:" +echo " Recent network errors (last 10 lines):" +adb -e logcat -d | grep -E "(NetworkMonitor|ECONNREFUSED|UnknownHostException)" | tail -5 +echo "" + +echo "🎯 Diagnosis Summary:" +echo "" + +# Determine issue type +if [ "$AIRPLANE_MODE" = "1" ]; then + echo "❌ PRIMARY ISSUE: Airplane mode is ON" + echo " Solution: Turn off airplane mode" +elif ! adb -e shell ping -c1 8.8.8.8 >/dev/null 2>&1; then + echo "❌ PRIMARY ISSUE: No internet connectivity" + echo " Solutions:" + echo " - Check host VPN/killswitch settings" + echo " - Verify firewall rules allow emulator traffic" + echo " - Try: ./launch-emulator-network-fix.sh" +elif ! adb -e shell ping -c1 connectivitycheck.gstatic.com >/dev/null 2>&1; then + echo "❌ PRIMARY ISSUE: DNS resolution failure" + echo " Solutions:" + echo " - Use explicit DNS: -dns-server 8.8.8.8,1.1.1.1" + echo " - Check corporate proxy settings" + echo " - Try: ./launch-emulator-network-fix.sh" +else + echo "✅ Network connectivity appears normal" + echo " If still experiencing ANRs, check Play Services cache:" + echo " adb -e shell pm clear com.google.android.gms" +fi + +echo "" +echo "🔧 Quick Fixes:" +echo " # Clear Play Services cache" +echo " adb -e shell pm clear com.google.android.gms" +echo " adb -e shell pm clear com.android.vending" +echo "" +echo " # Restart ADB" +echo " adb kill-server && adb start-server" +echo "" +echo " # Launch with network fixes" +echo " ./launch-emulator-network-fix.sh"