duckduckgo / ios-search-and-stories

DuckDuckGo Search & Stories for iOS
Other
176 stars 79 forks source link

No play icons on iPad anymore #128

Closed thm closed 8 years ago

thm commented 8 years ago

On iPad .gifv files don't seem to get the play-icon anymore. So, .gifv files can't be played. In native Safari it seems to be fine.

sreilly commented 8 years ago

@thm This is caused by our setting of the client-side navigator.userAgent setting to "DDG-iOS-appversion". That's the same version that is in the http request headers. We added this setting to help the search results page could suppress the red line at the top, and possibly other effects. Could we work with the web peeps to come up with a client-side user agent that looks more like a standard one that the gifv javascript is expecting?

thm commented 8 years ago

cc @nilnilnil @bsstoner

nilnilnil commented 8 years ago

@sreilly interesting, how did you confirm?

sreilly commented 8 years ago

@nilnilnil I just tried loading one of the .gifv story links with the setting on and then again with it off. You can try it by changing the property name on Line 56 of DDGSettingsViewController.m:

    @"UserAgent": [DDGUtility agentDDG],

This also sets the HTTP header, but the header is also set in another location too, so this setting only ends up affecting the client-side user agent that javascript sees.

nilnilnil commented 8 years ago

The short answer here is to use the DDG UA for DDG requests and the default UA for everything else.

sreilly commented 8 years ago

@nilnilnil That is what we're doing for the http requests, but the UA setting that client-side javascript looks at can't be set on a site-by-site basis. Basically, the javascript agent setting is an all-or-nothing thing. We either have to let iOS set the value for all sites (making the play button, and various other JS stuff "just work") or we set our own value that applies to all sites.

nilnilnil commented 8 years ago

Woah, that seems a bit intense. What docs are you looking at?

sreilly commented 8 years ago

I haven't found any official documentation on the client side navigator.userAgent setting, but there are a lot of posts on stackoverflow that describe how it works. Basically it's a setting that goes into the app-wide settings mechanism called NSUserDefaults. Because it's app-wide, it wouldn't be reliable to adjust it just before and after page loads in order to make it behave in a site-specific way.

However, I've changed the app-wide setting to use the default user-agent string with "; DDG-iOS-version" appended to it for both the navigator.userAgent javascript setting as well as the user-agent header for all sites other than duckduckgo.com. For duckduckgo.com requests it will simply use "DDG-iOS-version" but it would be nice to remove that special case, just for the sake of simplicity, if possible.

This change resolves this issue as well as #137, so I'll send it back to you @thm :)

bsstoner commented 8 years ago

Cool! Just a heads up, the detection internally needs slightly modified (it's looking for DDG at the beginning of the UA string). I just opened an internal PR to fix, but you may see the red bar come back in the meantime.

thm commented 8 years ago

Marking complete. @bsstoner noted!