This PR refactors debug adapter to handle two issues:
(1) - the debugAdapter.ts - file was becoming hard to manage due to it's versatility of use
(2) - solve problems with multiple sources triggering breakpoint updates at the same time
to solve (1) we separate out: CDPSession, SourceMapController and breakpointsController
to solve (2) we do the following:
a) move the responsibility of updating the breakpoints from breakpointsController to CDPBreakpoint class itself and queue CDP communication associated with that breakpoint such that we never request to set breakpoint with CDP until we get a response from previous breakpoint
b) we clear breakpoints registry when execution context is clear – we will get a new set of breakpoints once the new context is initialized
c) we only send InitializedRequest for DAP once main script is parsed. This triggers DAP to set breakpoints. Without this, we'd get breakpoints requests soon enough such that we wouldn't have the source map yet and hence we wouldn't be able to set them with CDP
d) we update logic for determining websocket URL for expo go – now we expect two runtimes to be present with expo go with the new debugger.
How Has This Been Tested:
Test the following scenarios related to debugging on both Android and iOS on various projects listed later:
Load IDE with breakpoint added – make sure the debugger stops at that breakpoint
Remove and add breakpoint while app is running – make sure the debugger stops at the new and doesn't stop at the removed one
Reload JS with breakpoint set – make sure breakpoint stops after reload
Fast refresh for a file with breakpoint set – make sure the breakpoint works after reload
This has been tested on different apps on Android and iOS:
test projects: expo-go, react-native-75, react-native-76 (new debugger), expo-52 (new debugger)
other projects: expo go SDK 52 project (debugger disconnects after reload JS here, but it seem to be issue with Expo Go which stops sending CDP messages regardless of the active CDP connection)
This PR refactors debug adapter to handle two issues: (1) - the
debugAdapter.ts
- file was becoming hard to manage due to it's versatility of use (2) - solve problems with multiple sources triggering breakpoint updates at the same timeto solve (1) we separate out:
CDPSession
,SourceMapController
andbreakpointsController
to solve (2) we do the following:a) move the responsibility of updating the breakpoints from
breakpointsController
toCDPBreakpoint
class itself and queue CDP communication associated with that breakpoint such that we never request to set breakpoint with CDP until we get a response from previous breakpoint b) we clear breakpoints registry when execution context is clear – we will get a new set of breakpoints once the new context is initialized c) we only send InitializedRequest for DAP once main script is parsed. This triggers DAP to set breakpoints. Without this, we'd get breakpoints requests soon enough such that we wouldn't have the source map yet and hence we wouldn't be able to set them with CDP d) we update logic for determining websocket URL for expo go – now we expect two runtimes to be present with expo go with the new debugger.How Has This Been Tested:
This has been tested on different apps on Android and iOS: