Bug 1503175

Summary: 3-pane inspector does not restore the previous column sizes
Product: [Components] DevTools Reporter: Patrick Brosset <:pbro> <pbrosset>
Component: InspectorAssignee: Vincent <grosbouddha>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: cornel.ionce, gl, grosbouddha, jcristau, jryans, mbalfanz
Version: unspecifiedKeywords: regression
Target Milestone: Firefox 65Flags: RyanVM: in‑testsuite+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: [dt-q]
relnote-firefox: --- Crash Signature:
Last Resolved: 2018-12-03 21:56:52 User Story:
QA Whiteboard: Iteration: ---
Points: --- Has Regression Range: ---
Has STR: --- tracking-geckoview66: ---
status-geckoview66: --- tracking-firefox-esr60: ---
status-firefox-esr60: unaffected status-firefox63: unaffected
status-firefox64: verified status-firefox65: verified
tracking-firefox66: --- status-firefox66: ---
tracking-firefox67: --- status-firefox67: ---
tracking-firefox68: --- status-firefox68: ---
Fission Milestone: ---
Bug Depends on:    
Bug Blocks: 1494162    
Attachments:
Description Flags
fix_inspector_layout_on_open.patch
none
fix_inspector_layout_on_open.patch
none
fix_inspector_layout_on_open.patch
none
fix_inspector_layout_on_open.patch gl: review+, jcristau: approval‑mozilla‑release+

Description User image Patrick Brosset <:pbro> 2018-10-30 01:20:32 PDT
I could swear we had this working in the past, so I'm a bit surprised. But better file it anyway:

Steps:
- open the inspector
- make sure you are in "3-pane mode" (if you see only 2 columns: DOM and CSS then click on the expand icon in the toolbar to see 3 columns: DOM, CSS and Layout)
- resize the 3 columns to whatever you like
- close the inspector
- re-open it again

==> The previous sizes aren't restored, which can be very frustrating.
Comment 1 User image Vincent 2018-11-09 03:05:16 PST
Can I take a look at this bug?

btw:
 - it can be reproduced with the 2 columns layout too,
 - it seems to be a recent regression: I can repro on a dev FF, it works fine on FF 63.0 (current prod).
Comment 2 User image Patrick Brosset <:pbro> 2018-11-09 05:32:47 PST
Of course, I'll assign it to you. I'm running a mozregression at the moment to find out which bug broke this, maybe this will help us find a solution.
Comment 3 User image Patrick Brosset <:pbro> 2018-11-09 05:49:00 PST
mozregression completed and pointed to this pushlog: https://hg.mozilla.org/integration/mozilla-inbound/pushloghtml?fromchange=409be898a58d93400ea8c6cad5d4385b64dc628a&tochange=3f01040106719f099339ebe65ff98690a65ee9f0

Out of the 2 bugs, the cause for this regression is probably bug 1494162. And in particular the patch part 29 in that bug broke this: https://hg.mozilla.org/integration/mozilla-inbound/rev/3f0104010671

So that confirms that this regressed in 64. This means as soon as we find a fix, we should not only land it in m-c as always, but also request an uplift so it also lands on the beta branch (in 64).

Vincent: don't worry about this for now, we have time to work on this, and I'll request the uplift whenever the time is right.
Comment 4 User image Vincent 2018-11-09 06:08:03 PST
Thanks for the assignment, taking a look now.

For reference, not all tabs seem to actually record their preferred size (verified on ff 63.0):
 - Splitbox storing/restoring width: inspector and style tabs
 - Splitbox not restoring: a11y and debugger tabs
 - Splitbox not draggable: canvas, memory
 - No Splitbox: console, network, webaudio, dom, shader, scratchpad
Comment 5 User image Vincent 2018-11-09 07:34:37 PST
I found the issue.
The sidebar's lifecycle was not properly tied to the inspector's lifecycle.
When the sidebar is destroyed or hidden, it stores the preferred widths for the various panels.
However, the inspector destroy was not calling the sidebar destroy properly.
Properties were never stored. At read time, the pref reading code was throwing and defaulting to the default width values.

The fix should be a one liner and uplift-friendly.
I still need to write a non-regression test.

After reading some of the lifecycle management JS code, I think there is some room for improvement here.
Not sure what's the best forum/mode to make an impactful proposal though.
Comment 6 User image Patrick Brosset <:pbro> 2018-11-09 07:43:54 PST
(In reply to Vincent from comment #5)
> After reading some of the lifecycle management JS code, I think there is
> some room for improvement here.
> Not sure what's the best forum/mode to make an impactful proposal though.
Great work so far! 
I suggest joining the public devtools-html slack and the #inspector channel there. The relevant people to include in this conversation would be @gl, @rcaliman I think.
Comment 7 User image Vincent 2018-11-09 10:00:52 PST
Created attachment 9024038 [details] [diff] [review]
fix_inspector_layout_on_open.patch
Comment 8 User image Vincent 2018-11-09 10:04:40 PST
Created attachment 9024041 [details] [diff] [review]
fix_inspector_layout_on_open.patch
Comment 9 User image J. Ryan Stinnett [:jryans] 2018-11-09 10:11:19 PST
Vincent, it looks like the review flag was cleared on the second version of the patch...  Is that one intended for review now?
Comment 10 User image Vincent 2018-11-09 10:52:23 PST
Created attachment 9024051 [details] [diff] [review]
fix_inspector_layout_on_open.patch

Adding back the patch with a review request. Thanks!
Comment 11 User image Vincent 2018-11-09 10:53:57 PST
Ready for review, thanks jryans!
Comment 12 User image Patrick Brosset <:pbro> 2018-11-11 06:34:08 PST
Comment on attachment 9024051 [details] [diff] [review]
fix_inspector_layout_on_open.patch

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

Thanks a lot Vincent for submitting a fix for this so quickly!
Let me pass this on to Gabriel since he was the one who worked on this originally.
Comment 13 User image Gabriel [:gl] (ΦωΦ) 2018-11-19 12:54:29 PST
Comment on attachment 9024051 [details] [diff] [review]
fix_inspector_layout_on_open.patch

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

::: devtools/client/inspector/test/browser_inspector_sidebarstate.js
@@ +41,5 @@
>  ];
>  
> +// Verify that the inspector properly read/write from user preferences to
> +// layout the inspector split boxes.
> +add_task(async function() {

We should move this to a new test file. Perhaps name it browser_inspector_pane_state_restore.js.

@@ +43,5 @@
> +// Verify that the inspector properly read/write from user preferences to
> +// layout the inspector split boxes.
> +add_task(async function() {
> +  // Simulate that the user already has stored splitboxes preferred widths.
> +  const EXPECTED_INITIAL_WIDTH = 101;

We should move these constants outside the add_task(). See https://searchfox.org/mozilla-central/source/devtools/client/inspector/test/browser_inspector_pane-toggle-03.js.

@@ +46,5 @@
> +  // Simulate that the user already has stored splitboxes preferred widths.
> +  const EXPECTED_INITIAL_WIDTH = 101;
> +  const EXPECTED_INITIAL_HEIGHT = 102;
> +  const EXPECTED_INITIAL_SIDEBAR_WIDTH = 103;
> +  Services.prefs.setIntPref(

We should use "await pushPref" to set these values.

@@ +53,5 @@
> +    "devtools.toolsidebar-height.inspector", EXPECTED_INITIAL_HEIGHT);
> +  Services.prefs.setIntPref(
> +    "devtools.toolsidebar-width.inspector.splitsidebar", EXPECTED_INITIAL_SIDEBAR_WIDTH);
> +
> +  // Open inspector.

We can remove this comment since it's implied by the function name.

@@ +54,5 @@
> +  Services.prefs.setIntPref(
> +    "devtools.toolsidebar-width.inspector.splitsidebar", EXPECTED_INITIAL_SIDEBAR_WIDTH);
> +
> +  // Open inspector.
> +  const res = await openInspectorForURL("about:blank");

Simplify to const { inspector } = await openInspectorForURL("about:blank");
Comment 14 User image Vincent 2018-11-19 14:37:37 PST
Thanks Gabriel for the review!
However, I'm on a vacation break this week and don't have access to my dev machine right now.
I will continue on this next week, most likely Tuesday/Wednesday.
Comment 15 User image Vincent 2018-11-29 12:27:17 PST
Created attachment 9028754 [details] [diff] [review]
fix_inspector_layout_on_open.patch

I applied your comments and ran eslint/mochitests.
I did a new round of local testing too since the original patch was quite old.

Please take another look to the updated patch.
Comment 16 User image Pulsebot 2018-12-03 07:57:47 PST
Pushed by gabriel.luong@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/decb54eeaa7d
Restore the previous inspector layout when reopening. r=gl
Comment 17 User image Gabriel [:gl] (ΦωΦ) 2018-12-03 07:58:41 PST
Thank you for the patch, Vincent. I made minor comment changes to your unit test and landed it.
Comment 18 User image Bogdan Tara[:bogdan_tara] 2018-12-03 13:56:52 PST
https://hg.mozilla.org/mozilla-central/rev/decb54eeaa7d
Comment 19 User image J. Ryan Stinnett [:jryans] 2018-12-06 11:48:12 PST
Maybe request uplift?
Comment 20 User image Ryan VanderMeulen [:RyanVM] 2018-12-10 14:22:00 PST
Note that Fx64 is being released tomorrow, so the approval request will need to be for mozilla-release for possible dot release inclusion.
Comment 21 User image Gabriel [:gl] (ΦωΦ) 2018-12-10 17:22:52 PST
Comment on attachment 9028754 [details] [diff] [review]
fix_inspector_layout_on_open.patch

[Beta/Release Uplift Approval Request]

Feature/Bug causing the regression: Bug 1503175

User impact if declined: 3-pane inspector does not restore the previous column sizes

Is this code covered by automated tests?: Yes

Has the fix been verified in Nightly?: No

Needs manual test from QE?: Yes

If yes, steps to reproduce: 1. Open the inspector in 3 pane mode.
2. Change the width of the any of the sidebars.
3. Close the devtools
4. Reopen the inspector
5. Check that the widths of the newly opened inspector is the same as before it was closed

List of other uplifts needed: None

Risk to taking this patch: Low

Why is the change risky/not risky? (and alternatives if risky): Covered by automated tests, and the code itself is a simply destroy method call to ensure the widths of the inspector is stored in the prefs when the devtools are closed.

String changes made/needed:
Comment 22 User image Julien Cristau [:jcristau] 2019-01-08 07:41:24 PST
Comment on attachment 9028754 [details] [diff] [review]
fix_inspector_layout_on_open.patch

looks safe enough to ride along in 64.0.2.
Comment 23 User image Julien Cristau [:jcristau] 2019-01-08 08:21:05 PST
https://hg.mozilla.org/releases/mozilla-release/rev/a2b5b227742b
Comment 24 User image Cornel Ionce [:cornel_ionce], Desktop Release QA 2019-01-09 01:42:02 PST
Reproduced this issue using Fx 64.0b buildID 20181206201918 on Windows 10 x64.

Confirming the fix across platforms using:
* 64.0.2, buildID 20190108160530
* 65.0b9, buildID 20190107180200