Skip to content
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

Implement Blob URL's DOM interfaces #11716

Merged
merged 1 commit into from Jun 17, 2016
Merged

Conversation

@izgzhen
Copy link
Contributor

izgzhen commented Jun 10, 2016

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.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix part of #10539, related to #11131
  • There are tests for these changes OR

This change is Reviewable

@highfive
Copy link

highfive commented Jun 10, 2016

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

highfive commented Jun 10, 2016

warning Warning warning

  • These commits modify net and script code, but no tests are modified. Please consider adding a test!
@izgzhen
Copy link
Contributor Author

izgzhen commented Jun 10, 2016

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
Member

Manishearth commented Jun 10, 2016

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(),

This comment has been minimized.

Copy link
@Manishearth

Manishearth Jun 10, 2016

Member

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

This comment has been minimized.

Copy link
@izgzhen

izgzhen Jun 11, 2016

Author Contributor

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

@izgzhen
Copy link
Contributor Author

izgzhen commented Jun 11, 2016

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
Member

Manishearth commented Jun 11, 2016

Good idea. #11722

@Manishearth
Copy link
Member

Manishearth commented Jun 11, 2016

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
Copy link
Contributor Author

izgzhen commented Jun 11, 2016

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.

@izgzhen izgzhen force-pushed the izgzhen:impl-blob-url-dom branch from c501d00 to 89c2aca Jun 11, 2016
@highfive
Copy link

highfive commented Jun 11, 2016

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

This comment has been minimized.

Copy link
@izgzhen

izgzhen Jun 11, 2016

Author Contributor

Noted both here and in BlobURLStoreMsg definition.


// https://w3c.github.io/FileAPI/#unicodeSerializationOfBlobURL
fn unicode_serialization_blob_url(origin: &str, id: &str) -> String {
// Step 1, 2

This comment has been minimized.

Copy link
@izgzhen

izgzhen Jun 11, 2016

Author Contributor

filled now. I feel like there is no more gaps to fill in this PR topic.

@Manishearth
Copy link
Member

Manishearth commented Jun 11, 2016

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

@bors-servo try

@bors-servo
Copy link
Contributor

bors-servo commented Jun 11, 2016

Trying commit 89c2aca with merge 6a19455...

bors-servo added 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 -->
@izgzhen izgzhen force-pushed the izgzhen:impl-blob-url-dom branch from 89c2aca to 6672534 Jun 11, 2016
@highfive
Copy link

highfive commented Jun 11, 2016

New code was committed to pull request.

@izgzhen
Copy link
Contributor Author

izgzhen commented Jun 11, 2016

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.

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

This comment has been minimized.

Copy link
@Manishearth

Manishearth Jun 11, 2016

Member

Why not?

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

This comment has been minimized.

Copy link
@Manishearth

Manishearth Jun 14, 2016

Member

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

@Manishearth
Copy link
Member

Manishearth commented Jun 11, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Jun 11, 2016

📌 Commit 6672534 has been approved by Manishearth

@Manishearth
Copy link
Member

Manishearth commented Jun 11, 2016

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
Contributor

bors-servo commented Jun 11, 2016

✌️ @izgzhen can now approve this pull request

@izgzhen
Copy link
Contributor Author

izgzhen commented Jun 11, 2016

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

@izgzhen izgzhen force-pushed the izgzhen:impl-blob-url-dom branch from 6672534 to 4f08428 Jun 11, 2016
bors-servo added 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
Member

Manishearth commented Jun 14, 2016

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
Contributor

bors-servo commented Jun 14, 2016

💔 Test failed - linux-rel

@highfive
Copy link

highfive commented Jun 14, 2016

  ▶ 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
Copy link
Contributor Author

izgzhen commented Jun 14, 2016

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

@bors-servo
Copy link
Contributor

bors-servo commented Jun 14, 2016

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

@izgzhen izgzhen force-pushed the izgzhen:impl-blob-url-dom branch from e419f66 to 47248dc Jun 14, 2016
@jdm
Copy link
Member

jdm commented Jun 14, 2016

Yes, I would prefer that.

@izgzhen
Copy link
Contributor Author

izgzhen commented Jun 15, 2016

@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
Contributor

bors-servo commented Jun 17, 2016

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

@jdm
Copy link
Member

jdm commented Jun 17, 2016

@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.

@izgzhen izgzhen force-pushed the izgzhen:impl-blob-url-dom branch from 47248dc to f514a94 Jun 17, 2016

// 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)));

This comment has been minimized.

Copy link
@izgzhen

izgzhen Jun 17, 2016

Author Contributor

@jdm changed here.

@izgzhen izgzhen force-pushed the izgzhen:impl-blob-url-dom branch from f514a94 to 4d33793 Jun 17, 2016
@jdm
Copy link
Member

jdm commented Jun 17, 2016

@bors-servo: r=Manishearth

@bors-servo
Copy link
Contributor

bors-servo commented Jun 17, 2016

📌 Commit 4d33793 has been approved by Manishearth

@bors-servo
Copy link
Contributor

bors-servo commented Jun 17, 2016

Testing commit 4d33793 with merge 0c9d0eb...

bors-servo added 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
Contributor

bors-servo commented Jun 17, 2016

@bors-servo bors-servo merged commit 4d33793 into servo:master Jun 17, 2016
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.