Skip to content

Commit

Permalink
don't submit v8 executor for adding breakpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
jamie-houston authored and Oleksii Trotsenko committed Jun 15, 2020
1 parent ca81c53 commit ed76b48
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 21 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ Later v8 executor will be passed to Chrome DevTools and used for performing debu

If Guava is already used in project - MoreExecutors and [ListenableFuture](https://github.com/google/guava/wiki/ListenableFutureExplained) could be handy.

### Known issues
- It's not possible to set break-point while debugging in progress.

Reason: Since V8 thread is suspended - setting new breakpoint is not possible as it must run on the same V8 thread.

### License

```
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:3.6.3"
classpath "com.android.tools.build:gradle:4.0.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.github.dcendents:android-maven-gradle-plugin:2.1"

Expand Down
1 change: 0 additions & 1 deletion j2v8-debugger-sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ android {
dataBinding{
enabled = true
}

}

ext {
Expand Down
23 changes: 9 additions & 14 deletions j2v8-debugger/src/main/java/com/alexii/j2v8debugger/Debugger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -122,30 +122,25 @@ internal class Debugger(
@Suppress("UNUSED_PARAMETER")
@ChromeDevtoolsMethod
fun setBreakpointByUrl(peer: JsonRpcPeer, params: JSONObject): SetBreakpointByUrlResponse? {
return runStethoAndV8Safely {
val responseFuture = v8Executor?.submit(Callable {
val request = dtoMapper.convertValue(params, SetBreakpointByUrlRequest::class.java)
request.url = request.scriptId
val request = dtoMapper.convertValue(params, SetBreakpointByUrlRequest::class.java)
request.url = request.scriptId
runStethoAndV8Safely {
v8Executor?.execute {
v8Messenger?.sendMessage(
Protocol.Debugger.SetBreakpointByUrl,
dtoMapper.convertValue(request, JSONObject::class.java)
)
val response = SetBreakpointByUrlResponse(request)
// Save breakpoint to remove on disconnect
breakpointsAdded.add(response.breakpointId)

response
})

responseFuture?.get()
}
}
val response = SetBreakpointByUrlResponse(request)
// Save breakpoint to remove on disconnect
breakpointsAdded.add(response.breakpointId)
return response
}

@Suppress("unused", "UNUSED_PARAMETER")
@ChromeDevtoolsMethod
fun removeBreakpoint(peer: JsonRpcPeer, params: JSONObject) {
//Chrome DevTools are removing breakpoint from UI regardless of the response (unlike setting breakpoint):
// -> do best effort to remove breakpoint when executor is free
runStethoAndV8Safely {
v8Executor?.execute {
v8Messenger?.sendMessage(
Expand Down

0 comments on commit ed76b48

Please sign in to comment.