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

Use the proper index when dragging a tab group #25160

Conversation

Ilie-Lesan
Copy link
Contributor

@Ilie-Lesan Ilie-Lesan commented Aug 16, 2024

Resolves brave/brave-browser#39486

Submitter Checklist:

  • I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run presubmit wiki, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

TabDragControllerTest.*
See the linked issue for manual test.

@Ilie-Lesan
Copy link
Contributor Author

@sangwoo108 Can you have a look. Thanks!

@simonhong
Copy link
Member

@tech-zilla Thanks for submitting.. I think this is the right fix.
As first item in drag_data_ is group header when detaching entire tab group,
we should iterate from first_tab_index() instead of 0. 👍🏼
Can you add test code for this also?

@Ilie-Lesan
Copy link
Contributor Author

@tech-zilla Thanks for submitting.. I think this is the right fix. As first item in drag_data_ is group header when detaching entire tab group, we should iterate from first_tab_index() instead of 0. 👍🏼 Can you add test code for this also?

@simonhong Thanks for the review. I will try to find some spare time for a test.

@Ilie-Lesan Ilie-Lesan requested a review from a team as a code owner September 30, 2024 00:28
@Ilie-Lesan
Copy link
Contributor Author

@simonhong I've added an interactive UI test for this crash and fixed the interactive_ui_tests. Please have a look to see if everything is ok.

@simonhong
Copy link
Member

simonhong commented Sep 30, 2024

@Ilie-Lesan Thanks for adding test.
We've not been running that test target on CI so far so interactive ui test seems broken now.
I think our CI we should run that target also in the future.
Before that, I think we should use browser test target.
Can you add your test code to browser test target instead as we don't run interactive target now?

@simonhong
Copy link
Member

and if you want to fix broken interactive ui test taget build as a separated issue, it's really welcome.

@@ -187,9 +187,9 @@ void TabDragController::DetachAndAttachToNewContext(
std::vector<tabs::TabHandle> tabs;
auto* tab_strip_model = browser->tab_strip_model();
DCHECK_EQ(tab_strip_model, attached_context_->GetTabStripModel());
for (const auto& tab_drag_data : drag_data_) {
for (size_t i = first_tab_index(); i < drag_data_.size(); ++i) {
Copy link
Member

@bsclifton bsclifton Sep 30, 2024

Choose a reason for hiding this comment

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

Nice- took me a minute to spot the fix 😄 Basically starting at first_tab_index and not iterating every item

Copy link
Collaborator

@cdesouza-chromium cdesouza-chromium Oct 16, 2024

Choose a reason for hiding this comment

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

Please change this to something like:

auto drag_data = base::span(drag_data_).subspan(first_tab_index());
for (const auto& tab_drag_data : drag_data) {
  ...

This will avoid build failures with the unsafe buffers warning as we don't access the subscript directly.

Copy link
Member

Choose a reason for hiding this comment

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

Oops - I missed this before merging; @Ilie-Lesan you're welcome to do a follow up or I can do that. Just let me know!

Copy link
Member

Choose a reason for hiding this comment

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

Pushed #26055

Copy link
Member

@bsclifton bsclifton left a comment

Choose a reason for hiding this comment

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

Code change looks great! Verified the fix in local build. Nice work 😄

+1 from me on the comments from @simonhong (RE: browser test would be great)

@Ilie-Lesan
Copy link
Contributor Author

Ilie-Lesan commented Sep 30, 2024

Code change looks great! Verified the fix in local build. Nice work 😄

+1 from me on the comments from @simonhong (RE: browser test would be great)

I will try to add a browser test(let's hope this can be done using the browser test target). Thanks for your time! :)

@bsclifton
Copy link
Member

Code change looks great! Verified the fix in local build. Nice work 😄
+1 from me on the comments from @simonhong (RE: browser test would be great)

I will try to add a browser test(let's hope this can be done using the browser test target). Thanks for your time! :)

You should be able to try it out via npm run test -- brave_browser_tests --filter="ClassNameOfTest.Testname". Basically, our CI is running npm run test -- brave_unit_tests and npm run test -- brave_browser_tests

@Ilie-Lesan
Copy link
Contributor Author

@simonhong I've added a browser test for the tab group drag issue. Let me know if everything is ok

@bsclifton bsclifton force-pushed the browser-crashed-while-dragging-tab-group-out-of-current-window branch from ecd32a8 to 890a61a Compare October 15, 2024 22:43
@bsclifton
Copy link
Member

Rebased and created a CI run here: #26018

@simonhong simonhong removed the request for review from a team October 16, 2024 01:07
@simonhong
Copy link
Member

simonhong commented Oct 16, 2024

checking the CI failures. My last commit didn't fix. Got same result after adding tab_strip->StopAnimating(true);
Disabled this test on macOS & Linux. Upstream also runs group detach test on Windows due to its flaky.

@simonhong simonhong force-pushed the browser-crashed-while-dragging-tab-group-out-of-current-window branch from 971c077 to 2543edb Compare October 16, 2024 06:08
upstream also only runs this test on Windows.
Also use //brave/browser/ui/views/tabs::browser_tests target for
tab browser test cases.
@simonhong simonhong force-pushed the browser-crashed-while-dragging-tab-group-out-of-current-window branch from 2543edb to 60990c1 Compare October 16, 2024 07:42
@simonhong
Copy link
Member

@bsclifton #26018 got all greens.
I think this PR can be merged but needs admin power.

Copy link
Collaborator

@cdesouza-chromium cdesouza-chromium left a comment

Choose a reason for hiding this comment

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

LGTM % changes.

Thanks for submitting this PR.

@bsclifton bsclifton merged commit 2724f43 into brave:master Oct 16, 2024
6 of 7 checks passed
@bsclifton
Copy link
Member

Nice work @Ilie-Lesan! Thanks for putting in the time on this one 😄

@bsclifton bsclifton added this to the 1.73.x - Nightly milestone Oct 16, 2024
@brave-builds
Copy link
Collaborator

Released in v1.73.18

@Ilie-Lesan
Copy link
Contributor Author

@bsclifton You're welcome, thanks too! :)

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.

Browser Crashed while dragging tab group out of current window
5 participants