Bug 172200 - iOS WebRTC Media Capture should not allow camera capture from background tab
Summary: iOS WebRTC Media Capture should not allow camera capture from background tab
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-05-16 16:55 PDT by youenn fablet
Modified: 2017-06-02 16:05 PDT (History)
7 users (show)

See Also:


Attachments
Patch (11.78 KB, patch)
2017-05-16 17:15 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (12.08 KB, patch)
2017-05-16 21:03 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews121 for ios-simulator-wk2 (919.81 KB, application/zip)
2017-05-16 22:48 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews100 for mac-elcapitan (1.17 MB, application/zip)
2017-05-17 05:15 PDT, Build Bot
no flags Details
Patch for landing (17.55 KB, patch)
2017-05-17 08:52 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews123 for ios-simulator-wk2 (14.17 MB, application/zip)
2017-05-17 10:50 PDT, Build Bot
no flags Details
Patch for landing (10.50 KB, patch)
2017-05-17 12:46 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (3.03 KB, patch)
2017-06-01 09:05 PDT, youenn fablet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description youenn fablet 2017-05-16 16:55:31 PDT
iOS WebRTC Media Capture should not allow camera capture from background tab
Comment 1 youenn fablet 2017-05-16 16:55:46 PDT
radar 32199028
Comment 2 youenn fablet 2017-05-16 17:01:19 PDT
rdar://problem/32199028
Comment 3 youenn fablet 2017-05-16 17:15:40 PDT
Created attachment 310324 [details]
Patch
Comment 4 youenn fablet 2017-05-16 21:03:43 PDT
Created attachment 310348 [details]
Patch
Comment 5 Build Bot 2017-05-16 22:48:30 PDT
Comment on attachment 310348 [details]
Patch

Attachment 310348 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/3757145

New failing tests:
platform/ios/mediastream/getUserMedia-disabled-in-background-tabs.html
Comment 6 Build Bot 2017-05-16 22:48:31 PDT
Created attachment 310351 [details]
Archive of layout-test-results from ews121 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews121  Port: ios-simulator-wk2  Platform: Mac OS X 10.11.6
Comment 7 Build Bot 2017-05-17 05:15:25 PDT
Comment on attachment 310348 [details]
Patch

Attachment 310348 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/3761981

New failing tests:
http/tests/media/hls/video-controls-live-stream.html
Comment 8 Build Bot 2017-05-17 05:15:26 PDT
Created attachment 310382 [details]
Archive of layout-test-results from ews100 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews100  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 9 Eric Carlson 2017-05-17 08:20:32 PDT
Comment on attachment 310348 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=310348&action=review

> Source/WebCore/ChangeLog:11
> +        On iOS, muting/unmuting the current video source according Document visibility.

Nit: "muting/unmuting" => "mute/unmute", "according" => "according to"

> Source/WebCore/dom/Document.cpp:6991
> +void Document::notifyVisibilityChangedToMediaCapture()
> +{
> +#if ENABLE(MEDIA_STREAM)
> +    RealtimeMediaSourceCenter::singleton().setVisibility(!hidden());
> +#endif
> +}

Nit: why is it necessary to put this one line call into a separate method?
Comment 10 Eric Carlson 2017-05-17 08:52:33 PDT
Comment on attachment 310348 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=310348&action=review

> LayoutTests/platform/ios/mediastream/getUserMedia-disabled-in-background-tabs.html:19
> +        let audioTrack = firstStream.getAudioTracks()[0];
> +        let videoTrack = firstStream.getVideoTracks()[0];

Where is firstStream set?
Comment 11 youenn fablet 2017-05-17 08:52:52 PDT
Created attachment 310394 [details]
Patch for landing
Comment 12 youenn fablet 2017-05-17 09:06:19 PDT
(In reply to Eric Carlson from comment #9)
> Comment on attachment 310348 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=310348&action=review
> 
> > Source/WebCore/ChangeLog:11
> > +        On iOS, muting/unmuting the current video source according Document visibility.
> 
> Nit: "muting/unmuting" => "mute/unmute", "according" => "according to"
> 
> > Source/WebCore/dom/Document.cpp:6991
> > +void Document::notifyVisibilityChangedToMediaCapture()
> > +{
> > +#if ENABLE(MEDIA_STREAM)
> > +    RealtimeMediaSourceCenter::singleton().setVisibility(!hidden());
> > +#endif
> > +}
> 
> Nit: why is it necessary to put this one line call into a separate method?

I did not want to pollute Document::visibilityStateChanged with too specific stuff.
That is why I went this way. I can go back and inline it directly though.

(In reply to Eric Carlson from comment #10)
> Comment on attachment 310348 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=310348&action=review
> 
> > LayoutTests/platform/ios/mediastream/getUserMedia-disabled-in-background-tabs.html:19
> > +        let audioTrack = firstStream.getAudioTracks()[0];
> > +        let videoTrack = firstStream.getVideoTracks()[0];
> 
> Where is firstStream set?

Fixed in the uploaded patch, I'll make sure it passes on the iOS simulator bot before committing the change.
Patch works on the device (manual testing)
Comment 13 Build Bot 2017-05-17 10:50:35 PDT
Comment on attachment 310394 [details]
Patch for landing

Attachment 310394 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/3763551

New failing tests:
platform/ios/mediastream/getUserMedia-disabled-in-background-tabs.html
Comment 14 Build Bot 2017-05-17 10:50:37 PDT
Created attachment 310410 [details]
Archive of layout-test-results from ews123 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews123  Port: ios-simulator-wk2  Platform: Mac OS X 10.11.6
Comment 15 youenn fablet 2017-05-17 12:46:49 PDT
Created attachment 310429 [details]
Patch for landing
Comment 16 youenn fablet 2017-05-17 13:27:56 PDT
Let's land it as is so that we have the correct behavior in the regular case.
And let's fix the more infrequent case of fullscreen mode (where camera should not be stopped) on a follow-up
Comment 17 WebKit Commit Bot 2017-05-17 14:08:29 PDT
Comment on attachment 310429 [details]
Patch for landing

Clearing flags on attachment: 310429

Committed r216999: <http://trac.webkit.org/changeset/216999>
Comment 18 WebKit Commit Bot 2017-05-17 14:08:31 PDT
All reviewed patches have been landed.  Closing bug.
Comment 19 Ryan Haddad 2017-05-17 15:24:17 PDT
(In reply to WebKit Commit Bot from comment #17)
> Comment on attachment 310429 [details]
> Patch for landing
> 
> Clearing flags on attachment: 310429
> 
> Committed r216999: <http://trac.webkit.org/changeset/216999>

This change broke the Windows build:
https://build.webkit.org/builders/Apple%20Win%20Release%20%28Build%29/builds/1574

WebCoreTestSupport.lib(JSInternals.obj) : error LNK2019: unresolved external symbol "public: void __thiscall WebCore::Internals::setPageVisibility(bool)" (?setPageVisibility@Internals@WebCore@@QAEX_N@Z) referenced in function "__int64 __cdecl WebCore::jsInternalsPrototypeFunctionSetPageVisibilityCaller(class JSC::ExecState *,class WebCore::JSInternals *,class JSC::ThrowScope &)" (?jsInternalsPrototypeFunctionSetPageVisibilityCaller@WebCore@@YA_JPAVExecState@JSC@@PAVJSInternals@1@AAVThrowScope@3@@Z) [C:\cygwin\home\buildbot\slave\win-release\build\WebKitBuild\Release\Tools\DumpRenderTree\DumpRenderTreeLib.vcxproj]
Comment 20 youenn fablet 2017-05-17 19:18:21 PDT
Thanks Ryan, I'll fix it asap

(In reply to Ryan Haddad from comment #19)
> (In reply to WebKit Commit Bot from comment #17)
> > Comment on attachment 310429 [details]
> > Patch for landing
> > 
> > Clearing flags on attachment: 310429
> > 
> > Committed r216999: <http://trac.webkit.org/changeset/216999>
> 
> This change broke the Windows build:
> https://build.webkit.org/builders/Apple%20Win%20Release%20%28Build%29/builds/
> 1574
> 
> WebCoreTestSupport.lib(JSInternals.obj) : error LNK2019: unresolved external
> symbol "public: void __thiscall WebCore::Internals::setPageVisibility(bool)"
> (?setPageVisibility@Internals@WebCore@@QAEX_N@Z) referenced in function
> "__int64 __cdecl
> WebCore::jsInternalsPrototypeFunctionSetPageVisibilityCaller(class
> JSC::ExecState *,class WebCore::JSInternals *,class JSC::ThrowScope &)"
> (?jsInternalsPrototypeFunctionSetPageVisibilityCaller@WebCore@@YA_JPAVExecSta
> te@JSC@@PAVJSInternals@1@AAVThrowScope@3@@Z)
> [C:\cygwin\home\buildbot\slave\win-
> release\build\WebKitBuild\Release\Tools\DumpRenderTree\DumpRenderTreeLib.
> vcxproj]
Comment 21 youenn fablet 2017-05-17 19:24:09 PDT
Filed bug 172257
Comment 22 youenn fablet 2017-06-01 09:05:24 PDT
Reopening to attach new patch.
Comment 23 youenn fablet 2017-06-01 09:05:24 PDT
Created attachment 311708 [details]
Patch
Comment 24 youenn fablet 2017-06-02 16:05:03 PDT
Test was improved as part of bug 172858.