mafredri / cdp

Package cdp provides type-safe bindings for the Chrome DevTools Protocol (CDP), written in the Go programming language.
MIT License
722 stars 46 forks source link

Protocol version #102

Open ziflex opened 5 years ago

ziflex commented 5 years ago

Hi!

I wonder what's the current version of the CDP protocol the library is using now? Since the protocol is still in flux, I need the number to properly stick to a particular version of Chrome.

mafredri commented 5 years ago

Hi, they were pulled from the JSON in ChromeDevTools/devtools-protocol on Jul 10, so that should be r674637.

But on that note, unless you're using bleeding edge methods, there shouldn't be much difference when using the latest protocol definition and running a few versions old Chrome 😄.

I could add the protocol version somewhere, e.g. commit message, maybe Version() on the client or a comment in a file, etc. Would that be helpful, any preference?

mafredri commented 5 years ago

PS. For best compatibility, pulling the protocol from the running browser (http://localhost:9222/json/protocol) and generating the cdp protocol from that would be the best option. Unfortunately, at the time of writing, this is not very straight forward.

I've been planning on moving to Go modules, and making a few adjustments to the protocol generator (cdpgen) to accommodate for this.

ziflex commented 5 years ago

Hi, they were pulled from the JSON in ChromeDevTools/devtools-protocol on Jul 10, so that should be r674637.

But on that note, unless you're using bleeding edge methods, there shouldn't be much difference when using the latest protocol definition and running a few versions old Chrome 😄.

I could add the protocol version somewhere, e.g. commit message, maybe Version() on the client or a comment in a file, etc. Would that be helpful, any preference?

I think version in README would be just fine.

The problem I'm facing is that the protocol works weird with new versions of Chrome. Not always, but its work is not consistently good or bad. Completely random issues appear here or there.

Therefore, I would like to know the version of the library in order to understand what range of browsers should be supported well. (if such exist at all)

mafredri commented 5 years ago

The problem I'm facing is that the protocol works weird with new versions of Chrome. Not always, but its work is not consistently good or bad. Completely random issues appear here or there.

That's weird, in my experience the protocol definition either works or it doesn't. So for example, if you're using a newer protocol definition and and older Chrome, and trying to run a command that's not supported on that version, you will get an error. It shouldn't cause any weird behavior.

From the cdp-packages perspective, there really is no difference between Chrome versions, the difference is only what commands are issued and with what parameters (i.e. the generated protocol definitions are really just a thin wrapper).

If you can give more specific examples of failures, and maybe point to example code that fails sporadically, I could look into it.

ziflex commented 5 years ago

I can't say that there is a pattern. Same operations may fail just randomly.

I guess because of if puppeteer uses specific version of Chrome.