Bug 135816 - [iOS] <video> element requests are missing session cookies; sometimes persistent cookies.
Summary: [iOS] <video> element requests are missing session cookies; sometimes persist...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Jer Noble
URL:
Keywords:
Depends on:
Blocks: 135825 135826
  Show dependency treegraph
 
Reported: 2014-08-11 14:33 PDT by Jer Noble
Modified: 2014-08-11 18:12 PDT (History)
9 users (show)

See Also:


Attachments
Patch (8.15 KB, patch)
2014-08-11 17:01 PDT, Jer Noble
ap: review+
Details | Formatted Diff | Diff
Patch for landing (8.47 KB, patch)
2014-08-11 17:31 PDT, Jer Noble
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jer Noble 2014-08-11 14:33:57 PDT
[iOS] <video> element requests are missing session cookies; sometimes persistant cookies.
Comment 1 Jer Noble 2014-08-11 17:01:06 PDT
Created attachment 236415 [details]
Patch
Comment 2 Jer Noble 2014-08-11 17:01:31 PDT
<rdar://problem/17912361>
Comment 3 Alexey Proskuryakov 2014-08-11 17:20:20 PDT
Comment on attachment 236415 [details]
Patch

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

> Source/WebCore/html/HTMLMediaElement.h:575
> +    virtual bool mediaPlayerGetRawCookies(const URL&, Vector<Cookie>&) const;

Please add "override" to this declaration.

Curious that "Cookie" worked without a forward declaration. Or will it break !ENABLE(VIDEO) builds?

> Source/WebCore/platform/graphics/MediaPlayer.h:268
> +    virtual bool mediaPlayerGetRawCookies(const URL&, Vector<Cookie>&) const { return false; }

It would be slightly more idiomatic to just return an empty vector as a value, and to have a notImplemented call in the base class version. Clients don't need to check at runtime whether their platform implements this.

> Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:718
> +static NSHTTPCookie* toNSHTTPCookie(const Cookie& cookie)

I think that Cookie class in WebCore is a better place for this code.

> Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:725
> +        NSHTTPCookieExpires: [NSDate dateWithTimeIntervalSince1970:(cookie.expires / 1000)],

It may be a good idea to pass NSHTTPCookieDiscard, assuming that it doesn't break anything. But I don't know abut how it interacts with NSHTTPCookieExpires.

Maybe the best thing to do is to have a FIXME about (1) the need to clarify this, and (2) move this code to Cookie class once it is generic enough.

> Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:726
> +        }];

Four too many spaces here, I think.
Comment 4 Jer Noble 2014-08-11 17:29:15 PDT
(In reply to comment #3)
> (From update of attachment 236415 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=236415&action=review
> 
> > Source/WebCore/html/HTMLMediaElement.h:575
> > +    virtual bool mediaPlayerGetRawCookies(const URL&, Vector<Cookie>&) const;
> 
> Please add "override" to this declaration.

Added.

> Curious that "Cookie" worked without a forward declaration. Or will it break !ENABLE(VIDEO) builds?

MediaPlayer.h forward declares it, and HTMLMediaElement.h includes MediaPlayer.h.

> > Source/WebCore/platform/graphics/MediaPlayer.h:268
> > +    virtual bool mediaPlayerGetRawCookies(const URL&, Vector<Cookie>&) const { return false; }
> 
> It would be slightly more idiomatic to just return an empty vector as a value, and to have a notImplemented call in the base class version. Clients don't need to check at runtime whether their platform implements this.

I tried that initially, but forward-declaring Cookie won't work in that case, as this pulls in the constructor and destructor of Vector<Cookie>.  I suspect that's why it was done with this kind of function signature for CookieJar.h as well.

> > Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:718
> > +static NSHTTPCookie* toNSHTTPCookie(const Cookie& cookie)
> 
> I think that Cookie class in WebCore is a better place for this code.

I agree; I'd like to move it into a platform-specific file in a follow up.

> > Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:725
> > +        NSHTTPCookieExpires: [NSDate dateWithTimeIntervalSince1970:(cookie.expires / 1000)],
> 
> It may be a good idea to pass NSHTTPCookieDiscard, assuming that it doesn't break anything. But I don't know abut how it interacts with NSHTTPCookieExpires.
> 
> Maybe the best thing to do is to have a FIXME about (1) the need to clarify this, and (2) move this code to Cookie class once it is generic enough.

I've figured this out, and i'll address it in the final patch. Turns out, it's the /presence/ of that key in the properties dictionary, not it's value, that determines the final result.

> > Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:726
> > +        }];
> 
> Four too many spaces here, I think.

Ok.
Comment 5 Jer Noble 2014-08-11 17:31:39 PDT
Created attachment 236416 [details]
Patch for landing
Comment 6 Jer Noble 2014-08-11 17:37:14 PDT
Committed r172422: <http://trac.webkit.org/changeset/172422>
Comment 7 Alexey Proskuryakov 2014-08-11 17:39:41 PDT
> MediaPlayer.h forward declares it, and HTMLMediaElement.h includes MediaPlayer.h.

I think that the include of MediaPlayer.h is conditional, which is why I said that it will break no-video builds.

> I tried that initially, but forward-declaring Cookie won't work in that case, as this pulls in the constructor and destructor of Vector<Cookie>.  I suspect that's why it was done with this kind of function signature for CookieJar.h as well.

The right thing to do it simply to move the implementation to .cpp file. Inline virtual functions are frequently harmful (they increase binary code bloat, and can't be inlined anyway).
Comment 8 Jer Noble 2014-08-11 18:01:37 PDT
(In reply to comment #7)
> > MediaPlayer.h forward declares it, and HTMLMediaElement.h includes MediaPlayer.h.
> 
> I think that the include of MediaPlayer.h is conditional, which is why I said that it will break no-video builds.

Ah, I see.  But the conditional wraps the entire header, so !VIDEO builds will be fine.

> > I tried that initially, but forward-declaring Cookie won't work in that case, as this pulls in the constructor and destructor of Vector<Cookie>.  I suspect that's why it was done with this kind of function signature for CookieJar.h as well.
> 
> The right thing to do it simply to move the implementation to .cpp file. Inline virtual functions are frequently harmful (they increase binary code bloat, and can't be inlined anyway).

Ok. All the MediaPlayerClient are inline-virtual, so moving them all into the .cpp file (or making them pure virtual, since there's only one subclass) we can do in a follow up.
Comment 9 Alexey Proskuryakov 2014-08-11 18:12:24 PDT
> But the conditional wraps the entire header, so !VIDEO builds will be fine.

Indeed, I misread it.