Google Maps onebox issues

.be link:
https://www.google.be/maps/place/Den+Abattoir/@51.2285173,4.4336702,17z/data=!4m7!1m4!3m3!1s0x47c3f7a5ac48e237:0x63d716018f584a33!2zUGnDqXRyYWlu!3b1!3m1!1s0x0000000000000000:0xfbfac0c41c32471a

.co.uk link:
https://www.google.co.uk/maps/place/Den+Abattoir/@51.2285173,4.4336702,17z/data=!4m7!1m4!3m3!1s0x47c3f7a5ac48e237:0x63d716018f584a33!2zUGnDqXRyYWlu!3b1!3m1!1s0x0000000000000000:0xfbfac0c41c32471a

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'
1 Like

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

Anyway, somewhere where the issue is visible:

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

I guess not; I’ll ask

Edit: Asked

Latest Beta:

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.

5 Likes

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.

2 Likes

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:

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

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.

6 Likes

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?

sure bump the version we can do an update.

1 Like

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.

https://www.google.com/maps/place/Fiji/@-17.4624892,179.2583049,7z/data=!3m1!4b1!4m2!3m1!1s0x6e1990fd703cdc5d:0x9e9c319946ef5b93

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

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

3 Likes

This issue is fixed now.

1 Like