|
|
Created:
6 years, 7 months ago by michaelbai Modified:
6 years, 7 months ago Reviewers:
boliu CC:
chromium-reviews, android-webview-reviews_chromium.org Base URL:
https://chromium.googlesource.com/chromium/src.git@master Visibility:
Public. |
DescriptionKeep the reference of passing request
Otherwise the request will be gc-ed, and There is no onRequestCancelled invoked.
BUG=375972
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=272268
Patch Set 1 #
Total comments: 5
Patch Set 2 : addressed comments #Patch Set 3 : #Patch Set 4 : fix findbug #Messages
Total messages: 16 (0 generated)
https://codereview.chromium.org/292183007/diff/1/android_webview/javatests/sr... File android_webview/javatests/src/org/chromium/android_webview/test/MediaAccessPermissionRequestTest.java (right): https://codereview.chromium.org/292183007/diff/1/android_webview/javatests/sr... android_webview/javatests/src/org/chromium/android_webview/test/MediaAccessPermissionRequestTest.java:144: if (mFirstRequest == awPermissionRequest) Does this mean any app using this api also have to do this? That seems bad. Why can't native AwPermissionRequest hold on to a strong ref to the java side? https://codereview.chromium.org/292183007/diff/1/android_webview/javatests/sr... android_webview/javatests/src/org/chromium/android_webview/test/MediaAccessPermissionRequestTest.java:159: assert (helper.canceled()); Assert is a language level thing, should be assertTrue, a junit condition test.
PTAL https://codereview.chromium.org/292183007/diff/1/android_webview/javatests/sr... File android_webview/javatests/src/org/chromium/android_webview/test/MediaAccessPermissionRequestTest.java (right): https://codereview.chromium.org/292183007/diff/1/android_webview/javatests/sr... android_webview/javatests/src/org/chromium/android_webview/test/MediaAccessPermissionRequestTest.java:144: if (mFirstRequest == awPermissionRequest) Right, it because the user could drop the request without responding to us, in this case the request should be GC-ed, and we can't hold the strong ref as we don't know whether user will respond us or not. On 2014/05/21 22:08:25, boliu wrote: > Does this mean any app using this api also have to do this? That seems bad. > > Why can't native AwPermissionRequest hold on to a strong ref to the java side? https://codereview.chromium.org/292183007/diff/1/android_webview/javatests/sr... android_webview/javatests/src/org/chromium/android_webview/test/MediaAccessPermissionRequestTest.java:159: assert (helper.canceled()); On 2014/05/21 22:08:25, boliu wrote: > Assert is a language level thing, should be assertTrue, a junit condition test. Done.
https://codereview.chromium.org/292183007/diff/1/android_webview/javatests/sr... File android_webview/javatests/src/org/chromium/android_webview/test/MediaAccessPermissionRequestTest.java (right): https://codereview.chromium.org/292183007/diff/1/android_webview/javatests/sr... android_webview/javatests/src/org/chromium/android_webview/test/MediaAccessPermissionRequestTest.java:144: if (mFirstRequest == awPermissionRequest) On 2014/05/21 22:17:04, michaelbai wrote: > Right, it because the user could drop the request without responding to us, in > this case the request should be GC-ed, and we can't hold the strong ref as we > don't know whether user will respond us or not. > > On 2014/05/21 22:08:25, boliu wrote: > > Does this mean any app using this api also have to do this? That seems bad. > > > > Why can't native AwPermissionRequest hold on to a strong ref to the java side? > Hmm, ok. Then apps can't rely on Cancel always being called. Not sure that's a great api design. You are holding on to the first request object. Does that on navigate, a second onPermissionRequest could come before the first one is cancelled?
On 2014/05/21 22:25:04, boliu wrote: > https://codereview.chromium.org/292183007/diff/1/android_webview/javatests/sr... > File > android_webview/javatests/src/org/chromium/android_webview/test/MediaAccessPermissionRequestTest.java > (right): > > https://codereview.chromium.org/292183007/diff/1/android_webview/javatests/sr... > android_webview/javatests/src/org/chromium/android_webview/test/MediaAccessPermissionRequestTest.java:144: > if (mFirstRequest == awPermissionRequest) > On 2014/05/21 22:17:04, michaelbai wrote: > > Right, it because the user could drop the request without responding to us, in > > this case the request should be GC-ed, and we can't hold the strong ref as we > > don't know whether user will respond us or not. > > > > On 2014/05/21 22:08:25, boliu wrote: > > > Does this mean any app using this api also have to do this? That seems bad. > > > > > > Why can't native AwPermissionRequest hold on to a strong ref to the java > side? > > > > Hmm, ok. Then apps can't rely on Cancel always being called. Not sure that's a > great api design. > > You are holding on to the first request object. Does that on navigate, a second > onPermissionRequest could come before the first one is cancelled? If users want to respond us, he should keep the strong ref of request, otherwise, it means he doesn't care about the request, in this case, we have warning in the log when the request is gc-ed, and because user doesn't care about the request, we shouldn't bother him about the cancellation of request. Q2: No it will not as I can see, if this test is flaky again, it might means the second request could come before cancel is called.
On 2014/05/21 22:34:02, michaelbai wrote: > Q2: No it will not as I can see, if this test is flaky again, it might means the > second request > could come before cancel is called. If the second request can not come before the first cancel, then can you change assert (junit kind) that mFirstRequest is null in onPermissionRequest, and assert it is not null in onPermissionRequestCanceled but set it to null at the end. Also just name it mRequest
PTAL
lgtm, thanks!
The CQ bit was checked by michaelbai@chromium.org
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/michaelbai@chromium.org/292183007/100001
FYI, CQ is re-trying this CL (attempt #1). Please consider checking whether the failures are real, and report flakes to chrome-troopers@google.com. The failing builders are: android_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/android_dbg/builds/18...)
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: android_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/android_dbg/builds/18...)
The CQ bit was checked by michaelbai@chromium.org
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/michaelbai@chromium.org/292183007/120001
Message was sent while issue was closed.
Change committed as 272268 |