Closed Bug 940537 Opened 11 years ago Closed 5 years ago

Remove the deprecated-sync-thenables from the debugger frontend

Categories

(DevTools :: Debugger, defect, P2)

defect

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: bbenvie, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 4 obsolete files)

      No description provided.
Attached patch promise-debugger.patch (obsolete) — Splinter Review
My initial work on this.
Blocks: dbg-frontend
Summary: Convert to Promise.jsm in the debugger front-end → Convert to Promise.jsm in the debugger frontend
Assignee: nobody → ejpbruel
Summary: Convert to Promise.jsm in the debugger frontend → Remove the deprecated-sync-thenables from the debugger frontend
I will take another look at this once I get back from vacation.
Removing the deprecated-sync-thenables from the debugger client causes one of the conditional breakpoint tests to fail.

On closer inspection, this test simulates a button click on a breakpoint, and then checks whether the UI has been properly updated. However, it does not wait for the button click to be fully processed before checking the UI, so this test is inherently racy.

This was not a problem when the frontend still used synchronous promises, since the button click would be entirely processed within a single tick of the event loop. With asynchronous promises, however, the button click is processed over several ticks of the event loop. As a result, the UI is not fully updated yet by the time the tests tries to check it.

The solution I came up with is to add an event that is emitted from the devtools window whenever a breakpoint click has been fully processed. Note that this does not completely solve the problem, as conditional breakpoints can asynchronously open a popup. This operation does not return a promise, so is not guaranteed to be completed when the BREAKPOINT_CLICKED event fires.

Though not perfect, this solution is at least an improvement on the previous situation, and makes the test pass locally.
Attachment #8661199 - Flags: review?(jlong)
Attachment #8335583 - Attachment is obsolete: true
Removing the deprecated-sync-thenables from the UI (specifically, the debugger-controller) causes most of the pretty print tests to fail.

The problem here is that the code that handles pretty printing in the debugger-controller tries to define a property on a promise. That was possible with the deprecated-sync-thenables, but Promise.jsm promises are not extensible.

The solution here is to store the property in question separate from the promise itself.
Attachment #8661202 - Flags: review?(jlong)
Comment on attachment 8661199 [details] [diff] [review]
Remove the deprecated-sync-thenables from the debugger client

Victor said he'd review these.
Attachment #8661199 - Flags: review?(jlong) → review?(vporof)
Attachment #8661202 - Flags: review?(jlong) → review?(vporof)
Comment on attachment 8661199 [details] [diff] [review]
Remove the deprecated-sync-thenables from the debugger client

Review of attachment 8661199 [details] [diff] [review]:
-----------------------------------------------------------------

::: browser/devtools/debugger/views/sources-view.js
@@ +1052,5 @@
>      }
>  
> +    promise.then(() => {
> +      window.emit(EVENTS.BREAKPOINT_CLICKED);
> +    });

This function begs to be rewritten in task.js
Attachment #8661199 - Flags: review?(vporof) → review+
Comment on attachment 8661202 [details] [diff] [review]
Remove the deprecated-sync-thenables from the UI

Review of attachment 8661202 [details] [diff] [review]:
-----------------------------------------------------------------

::: browser/devtools/debugger/debugger-controller.js
@@ +1402,5 @@
> +    if (cached && cached.pretty === wantPretty) {
> +      return cached.promise;
> +    }
> +
> +    let textPromise = new Promise((resolve, reject) => {

Please oh please don't mix Promise with promise.

Also please task I can't read this.
Attachment #8661202 - Flags: review?(vporof) → review-
New patch with comments addressed.

I understand your preference for Task.js. However, I'm not going to rewrite the patch at this point, since that would just be busywork. The point of this bug is to remove the deprecated-sync-thenables, so I'm aiming for the minimal change that will accomplish that.

That said, I have more patches coming up. I'll aim to use Task.js for those if it helps you review these.
Attachment #8661202 - Attachment is obsolete: true
Attachment #8661236 - Flags: review?(vporof)
Comment on attachment 8661236 [details] [diff] [review]
Remove the deprecated-sync-thenables from the UI

Review of attachment 8661236 [details] [diff] [review]:
-----------------------------------------------------------------

::: browser/devtools/debugger/debugger-controller.js
@@ +1402,5 @@
> +    if (cached && cached.pretty === wantPretty) {
> +      return cached.promise;
> +    }
> +
> +    let textPromise = new Promise((resolve, reject) => {

DOM Promises or imported promises? My previous comment stands...
Attachment #8661236 - Flags: review?(vporof) → review-
Eddy, this is going to directly conflict with my refactoring (which is done but we need to polish and get tests passing). I thought you know I was refactoring this part and was going to wait. 

My refactoring fixes all of this too, so I don't think you need to spend time on this. I think we can land it in a couple weeks, and that's only because I'm going to a conf next week. I'll talk to you tomorrow about this and see how we can collaborate to land my stuff.
I talked to James on irc, and we agreed that I will hold off from changing the promise implementation on the frontend until James can land his big refactor.

That said, switching promise implementations uncovers a lot of race conditions in our tests (I'm currently getting xpcshell test failures on try for the first patch). We need to fix those first anyway, and should be able to do so without actually changing the promise implementations. 

I'm going to hold off on this bug for now, and will open a separate bug for fixing said race conditions in individual tests. Note that we might not have to fix all tests, since some of them will be obsoleted by James' refactor anyway.
Depends on: 1205305
Discussed with :ejpbruel, I am going to make an attempt here now that :jlongster's refactor has landed.
Assignee: ejpbruel → jryans
Status: NEW → ASSIGNED
Comment on attachment 8700245 [details]
MozReview Request: Bug 940537 - Convert to Promise.jsm in debugger UI. r=jlongster

More test failures to resolve first.
Attachment #8700245 - Flags: review?(jlong)
Well, I got pretty close:

https://treeherder.mozilla.org/#/jobs?repo=try&revision=799fe691c719

The main failures are in browser_dbg_worker-window.js.  So far, I have not found an obvious fix.  :ejpbruel, any advice?
Flags: needinfo?(ejpbruel)
I vaguely remember discussing with you my fix for worker-window.js in bug 1132501. Did you try applying that? It's basically a one-liner. If not I can show you the fix again tomorrow.

That patch should land this week, just waiting on a review. If it seems to stall I plan on spinning out a few smaller bugs to land because I found a few things like this to fix.
(In reply to James Long (:jlongster) from comment #18)
> I vaguely remember discussing with you my fix for worker-window.js in bug
> 1132501. Did you try applying that? It's basically a one-liner. If not I can
> show you the fix again tomorrow.

Yes, I did include it, here's the variation I tried:

https://hg.mozilla.org/try/rev/0633ab493243

It did not appear to fix the errors I am seeing.
I don't have any advice how to fix the error at this point, since I'm also struggling with test failures for the same test. I talked to jryans and we agreed to spend some time tomorrow looking into this bug together.
Flags: needinfo?(ejpbruel)
If this is just for the front end, then I would suggest closing it, because the new front end doesn't use this module.
On the other hand, I notice that devtools/server still uses deprecated-sync-thenables :( so maybe this bug should
be repurposed.
Flags: needinfo?(jryans)
(In reply to Tom Tromey :tromey from comment #21)
> If this is just for the front end, then I would suggest closing it, because
> the new front end doesn't use this module.
> On the other hand, I notice that devtools/server still uses
> deprecated-sync-thenables :( so maybe this bug should
> be repurposed.

There are separate bugs for this issue in the RDP server (bug 1233890) and client (bug 1233891).

I think I'll hang onto this for now, since the old debugger code is still in tree and still used for Browser Toolbox.  If we happen to delete the old debugger without this fixed, then of course it would make sense to close this.  We'll see who wins... :)
Flags: needinfo?(jryans)
(I have looked at this again recently, but as usual, I get distracted by other things.)
Assignee: jryans → nobody
Status: ASSIGNED → NEW
Product: Firefox → DevTools
Closing this bug because it is specific to the old debugger ui.
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → WONTFIX
Blocks: 1565711
Blocks: 1565713
No longer blocks: 1565711
No longer blocks: 1565713
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: