New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 818206 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Apr 2018
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Bug
Proj-XR
Proj-XR-VR



Sign in to add a comment

VR: IME adapter isn't being initialized for VR correctly

Project Member Reported by mthiesse@chromium.org, Mar 2 2018

Issue description

I haven't tested to see which cases this is broken in, and how it's broken, but the logic isn't correct.

We're setting/restoring the VR IME adapter when switching tabs, but not when we switch content within a tab. This means that if we go from having no WebContents to having a WebContents, or the other way around, things will be broken.
 

Comment 1 by ericde@google.com, Mar 3 2018

Labels: hotlist-vrb-mvp
Related to initialization but not to "setting/restoring the VR IME adapter when switching tabs, but not when we switch content within a tab"

Found another bug:
Steps to repro:
1) Start with the new tabs page and enter VR
2) Go on a page with a web input field (e.g. wikipedia.org)
3) Spawn the keyboard and enter some text (note that entering text is needed to repro)
4) Click anywhere else to lose focus on the input field
5) Press back to go back to the native page. 

This should trigger a crash.
The crash is caused by a DCHECK failure in base::WeakPtrFactory: 
[FATAL:weak_ptr.cc(20)] Check failed: sequence_checker_.CalledOnValidSequence() || HasOneRef() WeakPtrs must be invalidated on the same sequenced thread

The crash suggests what we're invalidating the weak pts on the wrong thread. 
Context:
We create a unique_ptr<VrInputConnection> in VrShell on the main thread. We then create a weak ptr and send it to VrGlThread (the gl thread), which is holds a weak reference to. This is used to communicate keyboard changes from the gl thread to IME thread.

This happens in VrShell::SwapContents.
if (web_contents_) {
    vr_input_connection_.reset(new VrInputConnection(web_contents_));
    PostToGlThread(FROM_HERE,
                   base::BindOnce(&VrGLThread::SetInputConnection,
                                  base::Unretained(gl_thread_.get()),
                                  vr_input_connection_->GetWeakPtr()));
}

The crash happens because reset() calls the destructor of VrInputConnection, which calls invalidate() on each of the weak pointers, which ultimately results in the CHECK failure.

I can reliable repro this, but still haven't figured out why the DCHECK is failing.

I verified that we're invalidating on the main thread.
Labels: -Pri-1 -M-66 M-67 Pri-2
This appears to be a debug-only issue. Lowering priority and moving to 67.

Comment 4 by ericde@google.com, Mar 6 2018

does this repro (crash) on release builds? and if it's P2, it's not MVP right?
Project Member

Comment 5 by bugdroid1@chromium.org, Apr 6 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/8460d1bc090aed56b86845e7f3501a6d38d04f4f

commit 8460d1bc090aed56b86845e7f3501a6d38d04f4f
Author: Biao She <bshe@chromium.org>
Date: Fri Apr 06 23:12:07 2018

Fix a crash in debug build due to invalidate weakptr on wrong thread

The WeakPtr was first used on GL thread but invalidated on UI thread. So we
see a crash in debug build.
This CL uses a raw pointer instead of WeakPtr. It is safe to do so as
vr_gl_thread should be destroyed before vr_input_connection.

Bug:  818206 
Change-Id: I978df87d74e7823943858d48d0bc2d0947eecb01
Reviewed-on: https://chromium-review.googlesource.com/999824
Reviewed-by: Yash Malik <ymalik@chromium.org>
Commit-Queue: Biao She <bshe@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548958}
[modify] https://crrev.com/8460d1bc090aed56b86845e7f3501a6d38d04f4f/chrome/browser/android/vr/vr_gl_thread.cc
[modify] https://crrev.com/8460d1bc090aed56b86845e7f3501a6d38d04f4f/chrome/browser/android/vr/vr_gl_thread.h
[modify] https://crrev.com/8460d1bc090aed56b86845e7f3501a6d38d04f4f/chrome/browser/android/vr/vr_input_connection.cc
[modify] https://crrev.com/8460d1bc090aed56b86845e7f3501a6d38d04f4f/chrome/browser/android/vr/vr_input_connection.h
[modify] https://crrev.com/8460d1bc090aed56b86845e7f3501a6d38d04f4f/chrome/browser/android/vr/vr_shell.cc
[modify] https://crrev.com/8460d1bc090aed56b86845e7f3501a6d38d04f4f/chrome/browser/android/vr/vr_shell.h

Comment 6 by bshe@chromium.org, Apr 7 2018

Owner: bshe@chromium.org
Status: Fixed (was: Assigned)
Labels: Test-Complete

Sign in to add a comment