You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A-devtoolsC-assignedThere is someone working on resolving the issueE-more-complexVariable effort required; may require a mentor. Recommended solution is clearly described in the iss
There's a TODO about workers in propagate_console_msg. The easiest way forward is:
modify the SendConsoleMsg enum to include an Option<WorkerId> field
add a worker_id field to WorkerGlobalScope that is passed in as an argument in the constructor (new and new_inherited)
add a worker_id method to GlobalRef that returns None for a non-worker and the new field for a worker
modify propagate_console_msg to use the required GlobalRef methods instead of matching on the specific type
After these changes, it should be possible to connect to a worker from the devtools, execute a console.log("hi") and see it appear in the devtools console log.
adding a console_actor field to WorkerActor and filling it appropriately in handle_new_global
in handle_console_msg, pass in the actor_workers hashmap and use it to find the WorkerActor for the given WorkerId and PipelineId, and fetch the console actor based on the field added in the previous step
I did and I didn't. The field should be added to WorkerGlobalScope, which is inherited by DedicatedWorkerGlobalScope (for all practical purposes), so it should be passed in through the constructor of both DedicatedWorkerGlobalScope and WorkerGlobalScope.
@jdm I appreciate you helping me out as I'm new to Rust. Two more things:
Should the propagate_console_msg behave any differently if it matches to a worker?
Do you mind to explain your second point? I see what you're talking about, but I don't understand when we should find the WorkerActor unless we check for that and then get its ConsoleActor accordingly.
The code in propagate_console_msg should not behave any differently; there should be no match at all and it should get the values it requires directly from the GlobalRef methods.
in handle_console_message, if there's a non-None value for the worker id then we should search for a WorkerActor instead of a TabActor (using the worker id and pipeline id present in the message we received), and get the name of the appropriate ConsoleActor from this result. Does that make sense?
ifletSome(worker_id) = worker_id {let worker_actor_name = match worker_actors.get(&(id, worker_id)){Some(name) => name,None => return,};// find the worker actor, fetch the console_actor name from it, return the name}
It merged, so it should be possible to test this manually by connecting to a page with a worker (<script>new Worker('worker.js')</script>) and executing console.log('hi') in the web console that appears.
A-devtoolsC-assignedThere is someone working on resolving the issueE-more-complexVariable effort required; may require a mentor. Recommended solution is clearly described in the iss
Activity
HarryLovesCode commentedon Jul 31, 2015
@jdm I'd like to give this a shot, but I might need some help if you don't mind.
jdm commentedon Jul 31, 2015
@HarryLovesCode of course! Note that you won't be able to test changes until #6829 merges.
HarryLovesCode commentedon Jul 31, 2015
@jdm As a clarification, do you mean "anything except a worker" for the third point? Or do you mean a "non-worker" as in a window?
jdm commentedon Jul 31, 2015
Well, there are only Workers and Windows in GlobalRef, so the difference is only a semantic one :)
jdm commentedon Jul 31, 2015
Oh, the other part of this work is to modify
handle_console_message(http://mxr.mozilla.org/servo/source/components/devtools/lib.rs#256) to use the new WorkerId information to find the appropriate ConsoleActor that is associated with a worker.For that, I recommend:
console_actorfield toWorkerActorand filling it appropriately inhandle_new_globalhandle_console_msg, pass in theactor_workershashmap and use it to find theWorkerActorfor the givenWorkerIdandPipelineId, and fetch the console actor based on the field added in the previous stepHarryLovesCode commentedon Jul 31, 2015
@jdm Just making sure :). Also I don't see
WorkerGlobalScope::new()onlyWorkerGlobalScope::new_inherited(). Did you meanDedicatedWorkerGlobalScope?jdm commentedon Jul 31, 2015
I did and I didn't. The field should be added to WorkerGlobalScope, which is inherited by DedicatedWorkerGlobalScope (for all practical purposes), so it should be passed in through the constructor of both DedicatedWorkerGlobalScope and WorkerGlobalScope.
Also, if you need to do any testing of the devtools stuff, https://github.com/servo/servo/wiki/Devtools should have you covered.
HarryLovesCode commentedon Jul 31, 2015
@jdm I appreciate you helping me out as I'm new to Rust. Two more things:
propagate_console_msgbehave any differently if it matches to a worker?WorkerActorunless we check for that and then get itsConsoleActoraccordingly.jdm commentedon Jul 31, 2015
handle_console_message, if there's a non-Nonevalue for the worker id then we should search for aWorkerActorinstead of aTabActor(using the worker id and pipeline id present in the message we received), and get the name of the appropriateConsoleActorfrom this result. Does that make sense?HarryLovesCode commentedon Jul 31, 2015
It makes sense, but I'm not sure how to pattern match that... Sorry :/ Mind to lend a hand?
jdm commentedon Jul 31, 2015
Assuming something like
We can do this:
Is that more clear?
2 remaining items
jdm commentedon Jul 31, 2015
In theory there should be a backtrace of the failure showing up when that happens, and it should show who's calling unwrap.
HarryLovesCode commentedon Jul 31, 2015
@jdm Got it. Logging works from web workers (at least to the console), but devtools causes a crash. I assume #6829 will fix the issue with devtools?
jdm commentedon Aug 1, 2015
It might! We should be able to find out soon.
jdm commentedon Aug 1, 2015
It merged, so it should be possible to test this manually by connecting to a page with a worker (
<script>new Worker('worker.js')</script>) and executingconsole.log('hi')in the web console that appears.HarryLovesCode commentedon Aug 1, 2015
@jdm I'm trying to use the web console, but no logging appears at all (even a simple
console.log("TEST")from outside of a worker).HarryLovesCode commentedon Aug 1, 2015
@Wafflespeanut Oh! I see. My bad. I didn't notice you said it would appear in the "JSON-like stuff."
To answer the second part, I've done everything, but
handle_console_message.HarryLovesCode commentedon Aug 1, 2015
@Wafflespeanut That helps a lot. I'll commit the changes in a few minutes. I've got it working properly now. Sorry about the confusion.
Auto merge of #6893 - HarryLovesCode:master, r=jdm
frewsxcv commentedon Aug 3, 2015
We should probably create a regression test for this before closing
EDIT: or close this and open a new issue
jdm commentedon Aug 3, 2015
We can't without #5971, unfortunately.