`GeckoSession.mWindow` is not thread safe but is annotated that it can be accessed from multiple threads
Categories
(GeckoView :: General, defect, P1)
Tracking
(firefox-esr91 wontfix, firefox98 wontfix, firefox99 wontfix, firefox100 fixed)
People
(Reporter: mcomella, Assigned: agi)
Details
(Whiteboard: [geckoview:m98][geckoview:m99])
Attachments
(1 file)
GeckoSession.mWindow does not have synchronized access. GeckoSession.isOpen is annotated that it can be called from @AnyThread so GeckoSession.mWindow will need to be synchronized or otherwise changed to be thread safe.
The variable is initialized on the UI thread in GeckoSession.open and nulled again in GeckoSession.close or abandonWindow so the consequence of not fixing this is that background threads may read a stale value – either the initial null value or they'll get the Window after it's been closed.
Updated•4 years ago
|
Updated•4 years ago
|
| Assignee | ||
Comment 1•4 years ago
•
|
||
I think the @AnyThread in there is a mistake, I don't think we can reliably tell a consumer if a session is open on a background thread. Even with synchronized access to mWindow code like this will always be broken on a background thread:
if (!session.isOpen()) {
session.open(sGeckoRuntime);
}
because another thread could open the session between the isOpen() and the session.open statements.
We should just change isOpen to @UiThread and verify that all calls actually happen on the UI thread.
| Assignee | ||
Comment 2•4 years ago
|
||
The fact that isOpen is @AnyThread seems to be a mistake, I don't think we can
reliably tell a consumer if a session is open on a background thread.
Even with synchronized access to mWindow code like this would always be broken
on a background thread:
if (!session.isOpen()) {
session.open(sGeckoRuntime);
}
because another thread could open the session between the isOpen() and the
session.open statements.
This patch changes isOpen to @UiThread. I verified that all calls actually
happen on the UI thread, except for the calls in GeckoSessionSettings where we
are trying to handle the case where a session was closed and then we would
allow modifying read-only settings. I think in that case we should ask the
embedder to use a new SessionSettings instance instead of forcing all calls to
be @UiThread.
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Comment 4•4 years ago
|
||
Backed out for causing Lint failure.
Backout link: https://hg.mozilla.org/integration/autoland/rev/93daaede80eef1add213d205222cea9b39ae735f
Failure log: https://treeherder.mozilla.org/logviewer?job_id=370338043&repo=autoland&lineNumber=34871
Comment 6•4 years ago
|
||
| bugherder | ||
| Assignee | ||
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Description
•