Google Maps onebox issues


#1

.be link:

.co.uk link:

Both oneboxes show in preview, but not when cooked.

@boomzilla was able to uncover some extra info:
Job exception: undefined method 'split' for nil:NilClass

Env:

current_db: default
current_hostname: what.thedailywtf.com
message: While trying to onebox a URL
url: https://www.google.com.a/maps/place/Rheinbiss+652/@50.718779,7.129456,17z/data=!3m1!4b1!4m2!3m1!1s0x47bee15c59b6b135:0x9d379982efb7740b

Backtrace (partial):

/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/onebox-1.5.16/lib/onebox/engine/classic_google_maps_onebox.rb:31:in `resolve_url!'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/onebox-1.5.16/lib/onebox/engine/classic_google_maps_onebox.rb:10:in `initialize'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/onebox-1.5.16/lib/onebox/preview.rb:67:in `new'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/onebox-1.5.16/lib/onebox/preview.rb:67:in `engine'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/onebox-1.5.16/lib/onebox/preview.rb:13:in `to_s'

Job exception: bad argument (expected URI object or URI string)

current_db: default
current_hostname: what.thedailywtf.com
message: While trying to onebox a URL
url: http://www.google.co.uk/mapmaker
/usr/local/lib/ruby/2.0.0/uri/common.rb:998:in `URI'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/onebox-1.5.16/lib/onebox/engine/classic_google_maps_onebox.rb:31:in `resolve_url!'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/onebox-1.5.16/lib/onebox/engine/classic_google_maps_onebox.rb:10:in `initialize'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/onebox-1.5.16/lib/onebox/preview.rb:67:in `new'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/onebox-1.5.16/lib/onebox/preview.rb:67:in `engine'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/onebox-1.5.16/lib/onebox/preview.rb:13:in `to_s'
/var/www/discourse/lib/oneboxer.rb:126:in `block in onebox_raw'

#2

…and as luck would have it, they both work here :unamused:

Anyway, somewhere where the issue is visible:


(RĂ©gis Hanol) #3

I believe we’re recently fixed the google maps onebox. Are you running the latest version at TDW?


#4

I guess not; I’ll ask

Edit: Asked


#5

Latest Beta:


(Jens Maier) #6

Oh joy. Another type of Google maps URL…

The problem is that these URLs do not resolve into “canonical” URLs, so the current version of the oneboxer simply bails out. I have no idea why the one on meta accepts these URLs… is this perhaps actually an older version?

Anyway, I’ll take care of this.


#7

Except that the stuff works in the preview but not the final post (in the older version we’re running, not the latest version here on meta, where it all seems to work).

There have been (and surely still are) a lot of things that work differently in preview and final. Which is insane from a user’s point of view.


(Jens Maier) #8

Actually, no, things shouldn’t be working differently in preview and final. Both are processed by the same JavaScript code, and both invoke the same onebox engines. Oneboxes may be rendered differently in preview to avoid rapid reloading of iframes (after all, each time the preview is re-rendered, the entire cooked HTML is ripped out of the DOM and replaced), but as far as the GoogleMapsOnebox engine is concerned, both cases invoke the exact same code path through the initializer and resolve method.

As for why it works in preview but not in the final result? Heck if I knew. Right now, when you invoke the current version of GoogleMapsOnebox with either URL you’ve posted above, the engine’s initializer raises an ArgumentError because it doesn’t recognize the URL. :confused:


#9

…and the regexp describing google maps url would be joy to read :slight_smile:


(Jens Maier) #10

I have a fix here:

https://github.com/discourse/onebox/pull/293

This is a “best effort” solution.

  1. Previews must be static images or else each update of the composer preview pane would cause a reload of the embedded iframe. Google would probably consider this abuse, and browser performance would plummet straight to hell.

  2. I can only display static maps using data found in any of the available URLs that directly maps to data the static map API will accept. This is not the case for the cid field that contains the ID of the custom map, let alone the protobuf-encoded data field in the source URL. Thus, markers placed on custom maps will not appear on any previews.

  3. For a reason I have not (yet) figured out, Google’s webserver does sometimes, but not always, redirect @RaceProUK’s source URLs to the “canonical” Google maps URL. This seems to be totally random and may or may not be a transient problem. The engine now tries up to 10 times to get the canonical URL; if this fails, it constructs a fallback more or less blindly, based on assumptions and circumstancial evidence regarding the encoding of the data parameter.


(Jens Maier) #11

By the way: the second URL fails because you do have an outdated onebox version. classic_google_maps_onebox.rb no longer exists in the current version of the gem.

@zogstrip, should I bump onebox’s version in my PRs?


(Sam Saffron) #12

sure bump the version we can do an update.


(Bcguy) #13

Yes - my users are complaining about this issue too. I try to post a map, it shows up in preview, and for just a second or two in the final post, then it disappears.


#14

Yep, It’s already a month since last version update :smile:


(Arpit Jalan) #15

This issue seems to be fixed now? I can’t repro it.

Also there was an issue with Google Street View maps, just fixed that via:

https://github.com/discourse/onebox/commit/7369fc7528252fb87536ad9065455c5665ea5b5e


(Arpit Jalan) #16

This issue is fixed now.


(Arpit Jalan) #17