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

Fix missing textures on reloading three.js image content #22336

Merged
merged 1 commit into from Dec 1, 2018

Conversation

Projects
None yet
5 participants
@jdm
Member

jdm commented Nov 30, 2018

The fundamental problem is that three.js sets the crossOrigin property of an image, which kicks off an image microtask, and then sets the src. When the image URL is in the image cache (such as when reloading a page), this causes the shortcut to be taken and the image data is made available immediately, but the queued image task is unaware of this and asks the image cache to feed the image data. The existing code then ended up in an unexpected state when trying to deal with this data, such that when three.js received the image load notification and performed the texImage2D operation on the image data, it would discover that the image element did not claim to have a URL, and it would treat this as a broken image. Ultimately, this caused the texture that three.js obtained to be completely black.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #22152.

This change is Reviewable

@highfive

This comment has been minimized.

highfive commented Nov 30, 2018

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/htmlimageelement.rs
  • @KiChjang: components/script/dom/htmlimageelement.rs
@highfive

This comment has been minimized.

highfive commented Nov 30, 2018

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!
@jdm

This comment has been minimized.

Member

jdm commented Nov 30, 2018

@bors-servo try=wpt

@bors-servo

This comment has been minimized.

Contributor

bors-servo commented Nov 30, 2018

⌛️ Trying commit 896a2de with merge 2597b98...

bors-servo added a commit that referenced this pull request Nov 30, 2018

Auto merge of #22336 - jdm:image-reload, r=<try>
Fix missing textures on reloading three.js image content

The fundamental problem is that three.js sets the crossOrigin property of an image, which kicks off an image microtask, and then sets the src. When the image URL is in the image cache (such as when reloading a page), this causes the shortcut to be taken and the image data is made available immediately, but the queued image task is unaware of this and asks the image cache to feed the image data. The existing code then ended up in an unexpected state when trying to deal with this data, such that when three.js received the image load notification and performed the texImage2D operation on the image data, it would discover that the image element did not claim to have a URL, and it would treat this as a broken image. Ultimately, this caused the texture that three.js obtained to be completely black.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #22152.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22336)
<!-- Reviewable:end -->
@Manishearth

This comment has been minimized.

Member

Manishearth commented Nov 30, 2018

r=me

@bors-servo

This comment has been minimized.

Contributor

bors-servo commented Nov 30, 2018

☀️ Test successful - linux-rel-css, linux-rel-wpt
State: approved= try=True

@Manishearth

This comment has been minimized.

Member

Manishearth commented Nov 30, 2018

@bors-servo try- r+

@bors-servo

This comment has been minimized.

Contributor

bors-servo commented Nov 30, 2018

📌 Commit 896a2de has been approved by Manishearth

@bors-servo

This comment has been minimized.

Contributor

bors-servo commented Dec 1, 2018

⌛️ Testing commit 896a2de with merge a011682...

bors-servo added a commit that referenced this pull request Dec 1, 2018

Auto merge of #22336 - jdm:image-reload, r=Manishearth
Fix missing textures on reloading three.js image content

The fundamental problem is that three.js sets the crossOrigin property of an image, which kicks off an image microtask, and then sets the src. When the image URL is in the image cache (such as when reloading a page), this causes the shortcut to be taken and the image data is made available immediately, but the queued image task is unaware of this and asks the image cache to feed the image data. The existing code then ended up in an unexpected state when trying to deal with this data, such that when three.js received the image load notification and performed the texImage2D operation on the image data, it would discover that the image element did not claim to have a URL, and it would treat this as a broken image. Ultimately, this caused the texture that three.js obtained to be completely black.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #22152.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22336)
<!-- Reviewable:end -->
@bors-servo

This comment has been minimized.

Contributor

bors-servo commented Dec 1, 2018

@bors-servo bors-servo merged commit 896a2de into servo:master Dec 1, 2018

2 of 3 checks passed

continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details

bors-servo added a commit that referenced this pull request Dec 10, 2018

Auto merge of #22356 - jdm:image-reload-test, r=Manishearth
Add missing test for image reloading bug

This adds an automated test for #22336.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22356)
<!-- Reviewable:end -->

bors-servo added a commit that referenced this pull request Dec 10, 2018

Auto merge of #22356 - jdm:image-reload-test, r=Manishearth
Add missing test for image reloading bug

This adds an automated test for #22336.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22356)
<!-- Reviewable:end -->

bors-servo added a commit that referenced this pull request Dec 11, 2018

Auto merge of #22356 - jdm:image-reload-test, r=Manishearth
Add missing test for image reloading bug

This adds an automated test for #22336.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22356)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment