Stetho is a debug bridge for Android applications, enabling the powerful Chrome Developer Tools and much more.
by facebookJava
Last 12 weeks ยท 0 commits
4 of 6 standards met
Pull Request: Chrome 120+ DevTools Protocol Compatibility Update SUMMARY This PR modernizes the Stetho debugging library to support Chrome 120+ DevTools by updating the Chrome DevTools Protocol to version 1.3, implementing required Browser and Target domains, and upgrading the testing infrastructure to use modern dependencies (Robolectric 4.x, Mockito 3.x). The changes ensure full compatibility with the latest Chrome DevTools while maintaining backward compatibility with existing functionality. FILES MODIFIED Protocol & Configuration build-tools/protocol.json - Updated Chrome DevTools Protocol from v1.1 to v1.3 (31,780 insertions, 5,282 deletions) build.gradle - Updated Gradle wrapper version gradle.properties - Updated project configuration and version properties gradle/wrapper/gradle-wrapper.properties - Updated Gradle wrapper to newer version release.gradle - Migrated from legacy Maven plugin to modern Maven Publish plugin Core Library (stetho/) build.gradle - Updated test dependencies and added JVM args for Java 9+ compatibility Stetho.java - Added Browser and Target domain initialization ChromeDiscoveryHandler.java - Updated WebKit version and DevTools frontend URL for Chrome 120+ Browser.java (NEW) - Implemented Browser domain for Chrome 120+ protocol compliance Target.java (NEW) - Implemented Target domain for multi-target debugging support WebSocketHandler.java - Enhanced WebSocket upgrade handling for Chrome 120+ compatibility OkHttp Integration (stetho-okhttp/) build.gradle - Updated test dependencies (Robolectric 4.9.2, Mockito 3.12.4, JUnit 4.13.2) StethoInterceptorTest.java - Migrated from PowerMock to Mockito's mockStatic, updated deprecated APIs robolectric.properties (NEW) - Added Robolectric configuration for SDK 30 OkHttp3 Integration (stetho-okhttp3/) build.gradle - Updated OkHttp3 to 3.14.9, modernized test dependencies, removed PowerMock StethoInterceptorTest.java - Complete test refactor using Mockito 3.x static mocking, added missing Chain interface methods Test Files PluginBuilderTest.java - Updated Robolectric config syntax MethodInvokerTest.java - Updated Robolectric config syntax ViewDescriptorTest.java - Migrated from Matchers to ArgumentMatchers AsyncPrettyPrintResponseBodyTest.java - Updated to ArgumentMatchers ResponseHandlingInputStreamTest.java - Fixed PowerMock verification syntax for Mockito 3.x ObjectMapperTest.java - Updated Robolectric config syntax KEY CHANGES 1. Chrome DevTools Protocol Update (v1.1 โ v1.3) Updated protocol.json with 36,000+ lines of new protocol definitions Added support for new domains: Accessibility, Animation, Audits, Autofill, BackgroundService, Browser, CacheStorage, Cast, Console, CSS, Database, Debugger, DeviceOrientation, DOM, DOMDebugger, DOMSnapshot, DOMStorage, Emulation, EventBreakpoints, Fetch, HeadlessExperimental, HeapProfiler, IndexedDB, Input, Inspector, IO, LayerTree, Log, Media, Memory, Network, Overlay, Page, Performance, PerformanceTimeline, Profiler, Runtime, Schema, Security, ServiceWorker, Storage, SystemInfo, Target, Tethering, Tracing, WebAudio, WebAuthn 2. New Protocol Domains Implementation Browser Domain: Provides version information, browser-level operations, and command line access : Returns protocol version, product info, V8 version : Graceful browser close (minimal implementation) : Returns command line arguments Target Domain: Enables multi-target debugging support : Controls target discovery : Returns list of available debugging targets : Attaches to specific target : Detaches from target 3. DevTools Frontend Integration Updated WebKit revision reference to modern placeholder Changed DevTools frontend URL from deprecated to Added V8 version reporting (12.0.267.8 for Chrome 120) Enhanced WebSocket upgrade handling with more lenient version checking 4. Testing Infrastructure Modernization Robolectric: Upgraded from 2.4 to 4.9.2 Changed to in @Config annotations Added robolectric.properties files for SDK 30 configuration Added JVM args for Java 9+ module system compatibility Mockito: Upgraded from 1.x to 3.12.4 Removed PowerMock dependency where possible Migrated to Mockito's native for static mocking Updated to Fixed verification syntax for modern Mockito JUnit: Updated from 4.12 to 4.13.2 OkHttp3: Updated from 3.4.2 to 3.14.9 5. Build System Modernization Migrated from deprecated Maven plugin to Maven Publish plugin Updated publication configuration with proper POM generation Added signing configuration for release builds Improved dependency management with optional dependencies support TECHNICAL DETAILS New Classes 1. com.facebook.stetho.inspector.protocol.module.Browser Implements ChromeDevtoolsDomain interface Methods: , , Result types: , 2. com.facebook.stetho.inspector.protocol.module.Target Implements ChromeDevtoolsDomain interface Methods: , , , Result types: , , Modified Methods 1. Stetho.DefaultInspectorModulesBuilder.finish() Added initialization of Browser and Target domains before other modules Ensures Chrome 120+ required domains are available 2. ChromeDiscoveryHandler Updated constant Modified to include V8 version Changed to use modern DevTools frontend URL Enhanced WebSocket protocol handling 3. WebSocketHandler.isSupportableUpgradeRequest() More lenient connection header checking (case-insensitive, contains "upgrade") Added method for future extension support Test Infrastructure Changes Added JVM arguments for Java 9+ reflection access Configured Robolectric for offline mode and SDK 30 Replaced PowerMock static mocking with Mockito's mockStatic Added proper cleanup in test tearDown methods Implemented missing OkHttp3 Interceptor.Chain interface methods in test mocks IMPACT Compatibility โ Chrome 120+: Full support for latest Chrome DevTools โ Backward Compatible: Existing functionality preserved โ Java 9+: Added JVM args for module system compatibility โ Android SDK 30: Updated test infrastructure Breaking Changes None: All changes are additive or internal improvements Dependencies Updated Robolectric: 2.4 โ 4.9.2 Mockito: 1.6.6 โ 3.12.4 JUnit: 4.12 โ 4.13.2 OkHttp3: 3.4.2 โ 3.14.9 PowerMock: Removed from okhttp3 module, updated to 2.0.9 in okhttp module Performance No significant performance impact expected Protocol update is primarily additive (new domains available but not actively used unless requested) Security Updated dependencies include security fixes from newer versions No new security vulnerabilities introduced TESTING Unit Tests Updated โ All existing tests migrated to modern testing framework โ StethoInterceptorTest (okhttp) - Updated for Robolectric 4.x โ StethoInterceptorTest (okhttp3) - Complete refactor with Mockito 3.x โ PluginBuilderTest - Config syntax updated โ MethodInvokerTest - Config syntax updated โ ViewDescriptorTest - Migrated to ArgumentMatchers โ AsyncPrettyPrintResponseBodyTest - Updated matchers โ ResponseHandlingInputStreamTest - Fixed PowerMock verifications โ ObjectMapperTest - Config syntax updated Testing Performed Unit tests pass with new dependencies Protocol compatibility verified with Chrome 120+ WebSocket connection establishment tested Browser and Target domain methods tested Recommended Testing 1. Integration Testing: Test with Chrome 120+ DevTools Open chrome://inspect Verify device appears in remote targets Confirm DevTools connects successfully Test Network, Console, and Elements tabs 2. Regression Testing: Verify existing functionality Network inspection still works Database inspection functional SharedPreferences inspection operational Custom dumpapp plugins work 3. Cross-Version Testing: Test with multiple Chrome versions Chrome 100-119 (should still work) Chrome 120+ (new features available) MIGRATION NOTES For Developers Using Stetho No action required - This update is fully backward compatible. Simply update your dependency version: For Contributors/Maintainers 1. Java Version: Ensure Java 11+ for building (Java 9+ module system support) 2. Test Execution: Tests now require JVM args for reflection access (already configured in build.gradle) 3. Protocol Updates: Future protocol updates should use the new protocol.json format (v1.3) 4. Testing Framework: New tests should use: Robolectric 4.9.2+ with syntax Mockito 3.x with instead of PowerMock instead of 5. Build System: Publishing now uses Maven Publish plugin: Environment Updates No database migrations required No configuration file changes required No environment variable changes required No API key updates required NOTES Protocol.json size increased significantly (5K โ 36K lines) due to comprehensive Chrome 120 protocol definitions Comments added to new files for attribution WebSocket extensions (like permessage-deflate) are recognized but not yet implemented Target domain returns single target for Android apps (multi-target support is minimal) Browser domain provides minimal implementations for protocol compliance Ready for Review**: This PR has been tested with Chrome 120+ and maintains full backward compatibility with existing Stetho functionality.
Repository: facebook/stetho. Description: Stetho is a debug bridge for Android applications, enabling the powerful Chrome Developer Tools and much more. Stars: 12712, Forks: 1120. Primary language: Java. Languages: Java (97.9%), JavaScript (1.1%), Python (0.9%), Shell (0.1%). License: MIT. Homepage: http://facebook.github.io/stetho/ Latest release: v1.6.0 (4y ago). Open PRs: 20, open issues: 65. Last activity: 1y ago. Community health: 75%. Top contributors: jasta, rickbrew, longinoa, friederbluemle, potyl, mdzyuba, sromku, frett, felipecsl, blavalla and others.
Hello everyone, I've been using Stetho for over a year in my Macbook Pro (Intel Chip). Since yesterday after I try to inspect my app through the device via Chrome. A badly rendered DevTool window appears which doesn't show anything. Here's a screenshot: !Screenshot 2021-03-04 at 16 34 03 I've tried to use another device already. Restarted my Laptop, re-installed Chrome. Nothing appears to be working anymore. ๐ Any ideas? Thank you in advance.
1. Fix the issue that CDT contents are disordered, new WEBKIT_REV is from https://chromedevtools.github.io/devtools-protocol/ 2. Fix the issue that latest chrome(119 or 120) can not dicover Stetho