Skip to content

Implement Blob URL's DOM interfaces - #11716

Merged
bors-servo merged 1 commit into
servo:masterfrom
izgzhen:impl-blob-url-dom
Jun 17, 2016
Merged

bors-servo merged 1 commit into
servo:masterfrom
izgzhen:impl-blob-url-dom

Conversation

@izgzhen

@izgzhen izgzhen commented Jun 10, 2016 •

Copy link
Copy Markdown
Contributor

r? @Manishearth

Implement the two functions in URL to create/revoke Blob URLs, and related code to approximate our proposed design to make things work together.


  • There are tests for these changes OR

This change is Reviewable

@highfive

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @KiChjang: components/net/filemanager_thread.rs, components/script/lib.rs, components/net_traits/blob_url_store.rs, components/net_traits/blob_url_store.rs, components/script/dom/url.rs, components/script/dom/webidls/URL.webidl, components/script/dom/workerglobalscope.rs, components/net_traits/filemanager_thread.rs, components/net_traits/filemanager_thread.rs, components/script/blob_url_store.rs, components/script/dom/window.rs

@highfive

Copy link
Copy Markdown

warning Warning warning

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

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jun 10, 2016
@izgzhen

izgzhen commented Jun 10, 2016

Copy link
Copy Markdown
Contributor Author

I am still not very sure about how to deal with this: the net thread need the Origin, where might it come from? The script thread?

There are also other holes in the code, I might fix them later in this PR or following ones.

@Manishearth

Copy link
Copy Markdown
Member

For now just send it from the script thread and add a comment saying that net should actually be determining it from the pipeline id. Fetch/http_loader does this too right now. Its wrong, but I wouldn't bother fixing it for the purpose of this pr. If you want to we can try and fix it once everything else is working, otherwise it is on my list-of-things-I'll-eventually-do 😄

type_string: blob.Type().to_string(),
filename: None, // XXX: the filename is currently only in File object now
size: blob.Size(),
bytes: bytes.to_vec(),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shoudlnt we be checking for file blobs? And slice blobs, but you haven't implemented that yet.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right. I haven't yet make Blob as powerful as it is expected to. But this field is necessary anyway.

@izgzhen

izgzhen commented Jun 11, 2016

Copy link
Copy Markdown
Contributor Author

For now just send it from the script thread and add a comment saying that net should actually be determining it from the pipeline id. Fetch/http_loader does this too right now. Its wrong, but I wouldn't bother fixing it for the purpose of this pr. If you want to we can try and fix it once everything else is working, otherwise it is on my list-of-things-I'll-eventually-do 😄

Cool. Do we have an issue or something to track this?

@Manishearth

Copy link
Copy Markdown
Member

Good idea. #11722

@Manishearth

Copy link
Copy Markdown
Member

Okay, for now send the origin from script (and leave a comment saying we shouldn't trust it linking to that issue). If you want, we could land this first and focus on file blob uris later, or fix it in this PR itself, either way works for me.

@izgzhen

izgzhen commented Jun 11, 2016

Copy link
Copy Markdown
Contributor Author

Okay, I still have several gaps to fill. I am okay with the idea of leave a comment if the Origin proposal needs some time. Anyway I will keep tracking it.

@highfive

Copy link
Copy Markdown

New code was committed to pull request.

// https://w3c.github.io/FileAPI/#dfn-createObjectURL
pub fn CreateObjectURL(global: GlobalRef, blob: &Blob) -> DOMString {
/// XXX: Second field is an unicode-serialized Origin, it is a temporary workaround
/// and should not be trusted. See issue https://github.com/servo/servo/issues/11722

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted both here and in BlobURLStoreMsg definition.

@Manishearth

Copy link
Copy Markdown
Member

Do any new wpt tests pass? Do you know how to update expectations?

@bors-servo try

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Trying commit 89c2aca with merge 6a19455...

bors-servo pushed a commit that referenced this pull request Jun 11, 2016
Implement Blob URL's DOM interfaces

r? @Manishearth

Implement the two functions in `URL` to create/revoke Blob URLs, and related code to approximate our proposed design to make things work together.

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix part of #10539, related to #11131

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

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

Copy link
Copy Markdown

New code was committed to pull request.

@izgzhen

izgzhen commented Jun 11, 2016 •

Copy link
Copy Markdown
Contributor Author

Do any new wpt tests pass? Do you know how to update expectations?

Yes, sorry about that I forgot to check this out. I have pushed the new code.

Comment thread components/script/dom/url.rs Outdated

this method call does nothing. User agents may display a message on the error console.

XXX: First condition can't be enforced given current design

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not?

Anyway, this step seems to already be run on the fm thread, sort of.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this comment to mention that the first step is unnecessary, since closed blobs do not exist in the store.

@Manishearth

Copy link
Copy Markdown
Member

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 6672534 has been approved by Manishearth

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Jun 11, 2016
@Manishearth

Copy link
Copy Markdown
Member

looks like the manifest_changed thing failed.

Apply this diff, and r=manishearth

diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json
index f7861cb..9689adf 100644
--- a/tests/wpt/metadata/MANIFEST.json
+++ b/tests/wpt/metadata/MANIFEST.json
@@ -36026,6 +36026,12 @@
     "deleted_reftests": {},
     "items": {
       "testharness": {
+        "FileAPI/url/url_xmlhttprequest.html": [
+          {
+            "path": "FileAPI/url/url_xmlhttprequest.html",
+            "url": "/FileAPI/url/url_xmlhttprequest.html"
+          }
+        ],
         "cssom-view/scrolling-no-browsing-context.html": [
           {
             "path": "cssom-view/scrolling-no-browsing-context.html",

@bors-servo r- delegate+

@bors-servo

Copy link
Copy Markdown
Contributor

✌️ @izgzhen can now approve this pull request

@izgzhen

izgzhen commented Jun 11, 2016

Copy link
Copy Markdown
Contributor Author

Ahh my bad ... I thought both the ini and the metadata needs to be updated

@highfive

Copy link
Copy Markdown

New code was committed to pull request.

@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Jun 11, 2016
@highfive

Copy link
Copy Markdown
  ▶ CRASH [expected OK] /html/semantics/embedded-content/the-iframe-element/change_parentage.html
  │ 
  │ Xlib:  extension &#34;XFree86-VidModeExtension&#34; missing on display &#34;:0&#34;.
  │ ERROR:constellation::constellation: Panic: ScriptThread: received an event message for a layout channel that is not associated with this script thread.This is a bug.
  │ ERROR:constellation::constellation: Backtrace:
  │ frame #0  - 0x00007f21abc9103d - backtrace::backtrace::trace::hccde8df28b4db2a2
  │ frame #1  - 0x00007f21abc90fc5 - backtrace::capture::Backtrace::new::h42f95930bb8c5ee8
  │ frame #2  - 0x00007f21aacb4f69 - _&lt;F as alloc..boxed..FnBox&lt;A&gt;&gt;::call_box::h89adae1a802be550
  │ frame #3  - 0x00007f21abc82878 - util::panicking::initiate_panic_hook::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::he2b22674ad1748f3
  │ frame #4  - 0x00007f21abf5045c - std::panicking::rust_panic_with_hook::h983af77c1a2e581b
  │ frame #5  - 0x00007f21abf6a861 - std::panicking::begin_panic::he426e15a3766089a
  │ frame #6  - 0x00007f21abf51cca - std::panicking::begin_panic_fmt::hdddb415186c241e7
  │ frame #7  - 0x00007f21abf6a7fe - rust_begin_unwind
  │ frame #8  - 0x00007f21abfa0dff - core::panicking::panic_fmt::hf4e16cb7f0d41a25
  │ frame #9  - 0x00007f21abfa84b4 - core::option::expect_failed::hdb92832549f56a85
  │ frame #10 - 0x00007f21aacc1fa1 - script::script_thread::ScriptThread::handle_msg_from_script::h47e979ae1e7fb676
  │ frame #11 - 0x00007f21aad0ddaf - script::script_thread::ScriptThread::handle_msgs::_$u7b$$u7b$closure$u7d$$u7d$::hb50cf7fd97943b65
  │ frame #12 - 0x00007f21aacf5357 - script::script_thread::ScriptThread::handle_msgs::h1e1abab71191c950
  │ frame #13 - 0x00007f21aacb3657 - std::panicking::try::call::h78dcd5319adf08fa
  │ frame #14 - 0x00007f21abf74a5b - __rust_try
  │ frame #15 - 0x00007f21abf749fe - __rust_maybe_catch_panic
  │ frame #16 - 0x00007f21aacb48cd - _&lt;F as alloc..boxed..FnBox&lt;A&gt;&gt;::call_box::hce043844655ea6a9
  │ frame #17 - 0x00007f21abf68a24 - std::sys::thread::Thread::new::thread_start::h9c883b6d445ece46
  │ frame #18 - 0x00007f21a7da2181 - start_thread
  │ frame #19 - 0x00007f21a78b947c - __clone
  │ frame #20 - 0x0000000000000000 - &lt;unknown&gt;
  │ 
  └ ERROR:constellation::constellation: Pipeline failed in hard-fail mode.  Crashing!

@jdm

jdm commented Jun 14, 2016

Copy link
Copy Markdown
Member

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Trying commit e419f66 with merge 39498e7...

bors-servo pushed a commit that referenced this pull request Jun 14, 2016
Implement Blob URL's DOM interfaces

r? @Manishearth

Implement the two functions in `URL` to create/revoke Blob URLs, and related code to approximate our proposed design to make things work together.

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix part of #10539, related to #11131

<!-- Either: -->
- [x] There are tests for these changes OR

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

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

Copy link
Copy Markdown
Member

That happened because the blob: url for the worker source couldn't be loaded

oh, it tried to run a worker with a blob url. I didn't notice that 😄

@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-rel

@highfive highfive added the S-tests-failed The changes caused existing tests to fail. label Jun 14, 2016
@highfive

Copy link
Copy Markdown
  ▶ CRASH [expected OK] /html/semantics/embedded-content/the-iframe-element/change_parentage.html
  │ 
  │ Xlib:  extension &#34;XFree86-VidModeExtension&#34; missing on display &#34;:0&#34;.
  │ ERROR:constellation::constellation: Panic: ScriptThread: received an event message for a layout channel that is not associated with this script thread.This is a bug.
  │ ERROR:constellation::constellation: Backtrace:
  │ frame #0  - 0x00007f1e404c0eed - backtrace::backtrace::trace::hccde8df28b4db2a2
  │ frame #1  - 0x00007f1e404c0e75 - backtrace::capture::Backtrace::new::h42f95930bb8c5ee8
  │ frame #2  - 0x00007f1e3f4e4df9 - _&lt;F as alloc..boxed..FnBox&lt;A&gt;&gt;::call_box::h89adae1a802be550
  │ frame #3  - 0x00007f1e404b2728 - util::panicking::initiate_panic_hook::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::he2b22674ad1748f3
  │ frame #4  - 0x00007f1e4078030c - std::panicking::rust_panic_with_hook::h983af77c1a2e581b
  │ frame #5  - 0x00007f1e4079a711 - std::panicking::begin_panic::he426e15a3766089a
  │ frame #6  - 0x00007f1e40781b7a - std::panicking::begin_panic_fmt::hdddb415186c241e7
  │ frame #7  - 0x00007f1e4079a6ae - rust_begin_unwind
  │ frame #8  - 0x00007f1e407d0caf - core::panicking::panic_fmt::hf4e16cb7f0d41a25
  │ frame #9  - 0x00007f1e407d8364 - core::option::expect_failed::hdb92832549f56a85
  │ frame #10 - 0x00007f1e3f4f1e31 - script::script_thread::ScriptThread::handle_msg_from_script::h47e979ae1e7fb676
  │ frame #11 - 0x00007f1e3f53dc3f - script::script_thread::ScriptThread::handle_msgs::_$u7b$$u7b$closure$u7d$$u7d$::hb50cf7fd97943b65
  │ frame #12 - 0x00007f1e3f5251e7 - script::script_thread::ScriptThread::handle_msgs::h1e1abab71191c950
  │ frame #13 - 0x00007f1e3f4e34e7 - std::panicking::try::call::h78dcd5319adf08fa
  │ frame #14 - 0x00007f1e407a490b - __rust_try
  │ frame #15 - 0x00007f1e407a48ae - __rust_maybe_catch_panic
  │ frame #16 - 0x00007f1e3f4e475d - _&lt;F as alloc..boxed..FnBox&lt;A&gt;&gt;::call_box::hce043844655ea6a9
  │ frame #17 - 0x00007f1e407988d4 - std::sys::thread::Thread::new::thread_start::h9c883b6d445ece46
  │ frame #18 - 0x00007f1e3c5d2183 - start_thread
  │ frame #19 - 0x00007f1e3c0e937c - clone
  │ frame #20 - 0x0000000000000000 - &lt;unknown&gt;
  │ 
  └ ERROR:constellation::constellation: Pipeline failed in hard-fail mode.  Crashing!

@izgzhen

izgzhen commented Jun 14, 2016

Copy link
Copy Markdown
Contributor Author

@jdm Before I retry, do I have to consider the "Worker::PostMessage panicked" problem?

@bors-servo

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #11717) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added S-needs-rebase There are merge conflict errors. S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Jun 14, 2016
@jdm

jdm commented Jun 14, 2016

Copy link
Copy Markdown
Member

Yes, I would prefer that.

@izgzhen

izgzhen commented Jun 15, 2016

Copy link
Copy Markdown
Contributor Author

@jdm I checked the code a bit and found that the worker constructor will load resource (load_whole_resource) from the Blob URL, which will finally go to here.

However, since I have not yet routed the blob-kind request to file manager thread, it is supposed to return NetworkError or something (which might contribute to the TIMEOUT of worker? not sure), rather than crash out of no clear reason ...

Besides, I can't reproduce this locally, and also I am not ready to route the blob URL request yet (still needs more integration), I personally prefer to check if this PR will break again on homu and maybe submit a new issue for it (if it is unreproducible).

@bors-servo

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #11764) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Jun 17, 2016
@jdm

jdm commented Jun 17, 2016

Copy link
Copy Markdown
Member

@izgzhen It should be enough to use let _ = ... instead of the .unwrap() in Worker::PostMessage, since step 9 of https://html.spec.whatwg.org/multipage/comms.html#dom-messageport-postmessage indicates that a nonexistent communication channel should result in a silent error.


// NOTE: step 9 of https://html.spec.whatwg.org/multipage/comms.html#dom-messageport-postmessage
// indicates that a nonexistent communication channel should result in a silent error.
let _ = self.sender.send((address, WorkerScriptMsg::DOMMessage(data)));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdm changed here.

@jdm

jdm commented Jun 17, 2016

Copy link
Copy Markdown
Member

@bors-servo: r=Manishearth

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 4d33793 has been approved by Manishearth

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. S-needs-rebase There are merge conflict errors. labels Jun 17, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 4d33793 with merge 0c9d0eb...

bors-servo pushed a commit that referenced this pull request Jun 17, 2016
Implement Blob URL's DOM interfaces

r? @Manishearth

Implement the two functions in `URL` to create/revoke Blob URLs, and related code to approximate our proposed design to make things work together.

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix part of #10539, related to #11131

<!-- Either: -->
- [x] There are tests for these changes OR

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

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

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, windows

@bors-servo
bors-servo merged commit 4d33793 into servo:master Jun 17, 2016
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jun 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants