Skip to content

[FW][FIX] web: fix colorpicker "unknown CORS error" on safari#64389

Closed
fw-bot wants to merge 1 commit intoodoo:masterfrom
odoo-dev:master-14.0-web-colorpicker-unknown-cors-error-safari-fix-sad-Pey1-fw
Closed

[FW][FIX] web: fix colorpicker "unknown CORS error" on safari#64389
fw-bot wants to merge 1 commit intoodoo:masterfrom
odoo-dev:master-14.0-web-colorpicker-unknown-cors-error-safari-fix-sad-Pey1-fw

Conversation

@fw-bot
Copy link
Copy Markdown
Contributor

@fw-bot fw-bot commented Jan 12, 2021

Previously, when opening a colorpicker in safari, the crash manager
would open with the message "An unknown CORS error occured [...]". This
is actually odoo's default message when an error has no file, line or
column, which is usually the case for security reasons on CORS error.
This is however not a true CORS error, but a "ResizeObserver loop
completed with undelivered notifications" error, which also does not
report file, line and col for the error.

This error is caused by the fact that in webkit, the baseline of an
empty input is considered to be at the bottom of the input element,
rather than at the baseline of the text of the input once it has some
content. (see https://bugs.webkit.org/show_bug.cgi?id=142968 )

In the case of the colorpicker, it uses a ResizeObserver to update its
UI, including updating the content of its inputs. This will cause the
first _updateUI to fill the empty inputs, which changes the layout of
the widget content and changes its size. Changing the size of an element
inside of a handler of a ResizeObserver on that same element will cause
an error and not call the callback again, so as to prevent infinite
loop.

This commit fixes that by filling the inputs before attaching the
ResizeObserver, so that it has its final size from the get-go, and
_updateUI will no longer change the layout/size, causing this error.

opw-2419296

Forward-Port-Of: #64244

Previously, when opening a colorpicker in safari, the crash manager
would open with the message "An unknown CORS error occured [...]". This
is actually odoo's default message when an error has no file, line or
column, which is usually the case for security reasons on CORS error.
This is however not a true CORS error, but a "ResizeObserver loop
completed with undelivered notifications" error, which also does not
report file, line and col for the error.

This error is caused by the fact that in webkit, the baseline of an
empty input is considered to be at the bottom of the input element,
rather than at the baseline of the text of the input once it has some
content. (see https://bugs.webkit.org/show_bug.cgi?id=142968 )

In the case of the colorpicker, it uses a ResizeObserver to update its
UI, including updating the content of its inputs. This will cause the
first _updateUI to fill the empty inputs, which changes the layout of
the widget content and changes its size. Changing the size of an element
inside of a handler of a ResizeObserver on that same element will cause
an error and not call the callback again, so as to prevent infinite
loop.

This commit fixes that by filling the inputs before attaching the
ResizeObserver, so that it has its final size from the get-go, and
_updateUI will no longer change the layout/size, causing this error.

opw-2419296

X-original-commit: 5e9e35e
@robodoo
Copy link
Copy Markdown
Contributor

robodoo commented Jan 12, 2021

Pull request status dashboard

@robodoo robodoo added the forwardport This PR was created by @fw-bot label Jan 12, 2021
@fw-bot
Copy link
Copy Markdown
Contributor Author

fw-bot commented Jan 12, 2021

Ping @sdegueldre, @qsm-odoo
This PR targets master and is the last of the forward-port chain containing:

To merge the full chain, say

@fw-bot r+

More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port

@qsm-odoo
Copy link
Copy Markdown
Contributor

@fw-bot r+

@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label Jan 12, 2021
robodoo pushed a commit that referenced this pull request Jan 12, 2021
Previously, when opening a colorpicker in safari, the crash manager
would open with the message "An unknown CORS error occured [...]". This
is actually odoo's default message when an error has no file, line or
column, which is usually the case for security reasons on CORS error.
This is however not a true CORS error, but a "ResizeObserver loop
completed with undelivered notifications" error, which also does not
report file, line and col for the error.

This error is caused by the fact that in webkit, the baseline of an
empty input is considered to be at the bottom of the input element,
rather than at the baseline of the text of the input once it has some
content. (see https://bugs.webkit.org/show_bug.cgi?id=142968 )

In the case of the colorpicker, it uses a ResizeObserver to update its
UI, including updating the content of its inputs. This will cause the
first _updateUI to fill the empty inputs, which changes the layout of
the widget content and changes its size. Changing the size of an element
inside of a handler of a ResizeObserver on that same element will cause
an error and not call the callback again, so as to prevent infinite
loop.

This commit fixes that by filling the inputs before attaching the
ResizeObserver, so that it has its final size from the get-go, and
_updateUI will no longer change the layout/size, causing this error.

opw-2419296

closes #64389

X-original-commit: 5e9e35e
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
@robodoo robodoo closed this Jan 12, 2021
@robodoo robodoo temporarily deployed to merge January 12, 2021 12:15 Inactive
@sdegueldre sdegueldre deleted the master-14.0-web-colorpicker-unknown-cors-error-safari-fix-sad-Pey1-fw branch January 12, 2021 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

forwardport This PR was created by @fw-bot OE the report is linked to a support ticket (opw-...)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants