-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecating cdn.ampproject.org/v0/validator.js in favor of WebAssembly version #36110
Comments
Can you explain why this cannot be done as a backwards compatible change? (For clients that can execute wasm) |
It could be done. The WebAssembly validator (validator_wasm.js) has the same interfaces as the native validator (validator.js). Because it is a significant change, a new HTML parser and new validator engine, we thought it prudent to make it evident that this is different and the native version will no longer be supported. |
I think it is more in the spirit of AMP to be backwards compatible if at all possible, and to only require work by embedders if necessary. Also, my understanding is that on the npm side only the patch version was incremented (which was probably a mistake as it broke my tests from a timeout due to increased startup time of the WASM code) |
@cramforce keep in mind that this file is not an API layer, has never been described as an API layer in any documentation that I know of, and should probably not be considered an API layer. All of the APIs have been made to be backwards compatible. Embedders should neither be directly embedding this file nor the wasm one. Which isn't to say I'm opposed to keeping the filename constant, only that it should not really have been an issue either way. During the transition, there needed to be two simultaneous versions as not all tooling could be migrated in lockstep. Hence the creation of two files. It's not entirely clear that it's safe to switch clients using an undocumented API to a new implementation - we have no way to test it and it could produce unexpected results (like your timeout). |
@caoboxiao - there is also one incompatibility reason they need to be separate files. |
The WebAssembly validator is not 100% backward compatible with the previous native JavaScript validator, the The |
Thanks for the context. That breaking change does not apply to the node.js module, right? |
If I'm reading everything right, the node module API remains the same? amphtmlValidator.getInstance().then(function (validator) {
validator.validateString(…)
}); Because I'm interested in what is generating the |
Yes, |
|
We should discuss this item. Why would the default change before the source is open? |
The source code is available in GitHub and open-source, we just need to get the build script working in GitHub. |
Oh, that makes sense, thanks for the clarification. @rsimha Not sure if this is on your radar, but wanted to make sure it was known. |
Seems like you're looking for approvers. I approve, once the build system is open-source and others can generate the wasm representation for future JS/WASM hosting. |
After merging #37367, the building of the WebAssembly version AMP validator is now open-source. |
Approved. |
Based on #36110 (comment) and #36110 (comment), I approve this change. |
Also approved. This is clear to proceed. |
For developers seeing this error message
|
The AMP validator task was returning a deprecation message. This updates to the latest version as stated as the reccommendation in: ampproject/amphtml#36110 (comment)
Hi, there seems to be an issue with the Wasm loading / initializing that was reported in #38401 (and partially in #36404 as well), which breaks the NPM package as well as requiring a workaround inside the repo (amp.validation.init) and importing the script that doesn't work in the NPM package. The API described in the documentation ( However, when importing directly |
Summary
The AMPHTML Validator ensures that critical features of the AMPHTML spec are followed within AMP related documents. It is maintained by a set of rules and engines written in C++ and JavaScript that apply those rules during validation. There are many developer tools that utilize these validator engines to assist in the development of valid AMP documents.
Due to ongoing complexity and developer maintenance of two validator engines, the Caching Working Group is deprecating the native JavaScript validator in favor of a WebAssembly validator which uses the C++ engine.
Existing developer tools such as the Validator Web UI, Chrome Extension, VS Code Extension and Node.js Package have already migrated to the WebAssembly validator.
To inform existing developers using validator.js directly and not through one of these developer tools, the APIs in validator.js will be deprecated to return an error message to update tooling to use validator_wasm.js and it will no longer provide validation. This was released for a short time on Monday, September 13, 2021 before being rollbacked. It will be released again on Thursday, September 23, 2021 pending approval here.
Developers unable to migrate to the WebAssembly validator immediately due to compatibility issues, will be able to utilize a temporary fallback to the native JavaScript validator (validator.20211101.deprecated.js). This will be removed on November 1, 2021.
Motivation
The AMPHTML Validator has two implementations. One in C++ and one in JavaScript. These utilize different HTML parsers which at times can cause differences between validation results of documents. Over time these differences have been reduced. However, there is ongoing complexity and maintenance costs in keeping these two implementations in sync. With a WebAssembly validator version released, it is no longer necessary to continue to endure those costs by deprecating the native JavaScript version in favor of the WebAssembly version.
Impact on Existing Users
Developers utilizing validator.js directly from the Google AMP Cache will need to upgrade to using the WebAssembly version (validator_wasm.js). A temporary fallback version is provided until November 1, 2021.
Alternative Implementation
A temporary fallback version is provided until November 1, 2021 via
https://cdn.ampproject.org/v0/validator.20211101.deprecated.js
. Ideally they would upgrade tohttps://cdn.ampproject.org/v0/validator_wasm.js
or utilize an existing developer tool such as the Node.js Package.Additional Context
Example of messaging returned by the deprecated native JavaScript validator via Node.js Package:
Example of messaging returned by the deprecated native JavaScript validator via DevTools:
Notifications
/cc @ampproject/wg-approvers
The text was updated successfully, but these errors were encountered: