JDK-8126811 : Google Maps in WebView causes exception on Ubuntu
  • Type: Bug
  • Component: javafx
  • Sub-Component: web
  • Affected Version: 7u6,8
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2012-06-25
  • Updated: 2015-06-17
  • Resolved: 2013-05-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
Run the WebMap demo:

    ant -f apps/internal/WebMap/build.xml run

and attempt to drag the map. The map will not move. On the third or fourth attempt the program will dump the following exception:

     [java] java.lang.NullPointerException: Clipboard.putContent: null data
     [java]     at com.sun.javafx.tk.quantum.QuantumClipboard.putContent(QuantumClipboard.java:442)
     [java]     at javafx.scene.input.Clipboard.setContent(Clipboard.java:226)
     [java]     at com.sun.webpane.sg.UIClientImpl.confirmStartDrag(UIClientImpl.java:178)
     [java]     at com.sun.webpane.platform.WebPage.confirmStartDrag(WebPage.java:861)
     [java]     at javafx.scene.web.WebView$18.handle(WebView.java:1145)
     [java]     at javafx.scene.web.WebView$18.handle(WebView.java:1142)
     [java]     at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:69)
     [java]     at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)
     [java]     at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)
     [java]     at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
     [java]     at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
     [java]     at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
     [java]     at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
     [java]     at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
     [java]     at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
     [java]     at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:33)
     [java]     at javafx.event.Event.fireEvent(Event.java:171)
     [java]     at javafx.scene.Scene$DnDGesture.fireEvent(Scene.java:2592)
     [java]     at javafx.scene.Scene$DnDGesture.process(Scene.java:2671)
     [java]     at javafx.scene.Scene$DnDGesture.access$8700(Scene.java:2568)
     [java]     at javafx.scene.Scene$MouseHandler.process(Scene.java:3305)
     [java]     at javafx.scene.Scene$MouseHandler.process(Scene.java:3129)
     [java]     at javafx.scene.Scene$MouseHandler.access$1900(Scene.java:3084)
     [java]     at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1524)
     [java]     at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2226)
     [java]     at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:227)
     [java]     at com.sun.glass.ui.View.handleMouseEvent(View.java:528)
     [java]     at com.sun.glass.ui.View.notifyMouse(View.java:921)
     [java]     at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
     [java]     at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
     [java]     at com.sun.glass.ui.win.WinApplication$2$1.run(WinApplication.java:62)
     [java]     at java.lang.Thread.run(Thread.java:722)

With JavaFX 8.0 b86, when running WebView outside of the WebMap sample, an exception does occur on Ubuntu 12.04 with Google Maps.  To reproduce the problem, use Ensemble or another app that uses WebView to implement a web browser and navigate to:

https://google-developers.appspot.com/maps/documentation/javascript/examples/map-simple

Exercise different events like panning.
Comments
Setting the user agent header from within sun.net.www.protocol.http.Handler.openConnection is unlikely to have any effect as WebView sets its value later in the process. I am not sure if this whole approach is a good idea in general but if you subclass Http[s]URLConnection and override the connect (or similar) method to overwrite the user agent header, that might work.
10-09-2013

Any workaround for 2.2? I tried to register a custom URLStreamHandlerFactory, which is correctly forwarding the HTTP/HTTPS requests to my handlers, and change the User Agent, like suggested: public class JavaFXHTTPHandler extends sun.net.www.protocol.http.Handler { @Override protected URLConnection openConnection(URL url) throws IOException { URLConnection ret = super.openConnection(url); ret.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.2 (KHTML, like Gecko) JavaFX/8.0 Safari/537.2"); return ret; } } but that didn't solve my problems. Any suggestion?
10-09-2013

Disabling touch event support seems inevitable as it's causing so many bugs. Here's the webrev that was initially proposed for RT-30080: http://javaweb.us.oracle.com/jcg/fx-webrevs/RT-22914/2
23-05-2013

Fixed in changeset http://jfxsrc.us.oracle.com/javafx/8.0/scrum/graphics/rt/rev/41ed915dab1a
23-05-2013

Apparently Google Maps do UA sniffing and behave differently if JavaFX WebView 's UA string contains 'Linux' instead of 'Windows'. The problem disappears on Linux if I set the UA string to what it defaults on Windows: webEngine.setUserAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.2 (KHTML, like Gecko) JavaFX/8.0 Safari/537.2"); Does this work as a workaround for your guys? What happens is, when seeing 'Linux' in the UA string, Google Maps apparently still turns on the old mode in which the existence of touch events disables mouse events. The problem should disappear if and when we disable touch events, that is, revert RT-21052.
21-05-2013

I just tried on Ubuntu 12.04 and FX 8, b86 with WebView but outside of the WebMap sample. I also get an exception java.lang.IllegalArgumentException: Image dimensions must be >0 ... All works well on Mac, though. Am asking WebView to please take a look.
24-04-2013

Any news on this issue on Linux?
24-04-2013

I'm not sure what you mean when you say they 'work fine outside of WebMap'. When you say the stock maps examples both work, do you mean they work in Firefox/Chrome (non-WebView?). Of course they work in a normal browser, the point is that they don't work in JavaFX WebView. Assuming you mean JavaFX, are you testing on a Linux machine? I just opened the stock V3 example in a new WebView on 8b84-64bit Linux, and it still does not work (doesn't drag, throws exceptions). Fails out side of WebMap: http://pastebin.com/gdYxjFA0 8.0.0-ea-b84 Oracle Corporation 1.8.0-ea Linux amd64 3.2.0-23-generic
13-04-2013

Stock maps examples, both v2 and v3, work fine outside WebMap: https://google-developers.appspot.com/maps/documentation/javascript/examples/map-simple https://google-developers.appspot.com/maps/documentation/javascript/v2/examples/map-simple
12-04-2013

As per previous conversation (about a month ago), this is NOT a bug with the sample. The sample is properly using the latest version of the API. The stock maps.google.com is a very DIFFERENT implementation of maps and is NOT comparable. Using the stock google-maps-api-example would make much more reasonable (it fails, by the way). Reassigning to 'Samples' makes no sense, as the bug clearly isn't on their end.
12-04-2013

Tested on Linux with current 8.0 bits. The demo works except for Google maps: they don't react on mouse events at all. Since stock maps.google.com work fine, reassigning to Samples. Probably newer maps version should be used, see previous comments. Another issue is that mouse wheel doesn't work with Y! maps either in WebMap or in WebLauncher. The cause is likely the same touch/mouse event conflict on Yahoo side.
12-04-2013

There is nothing wrong with the demo itself. The stock maps.google.com has always worked. The Google Maps API V2 (deprecated) also always worked. The demo uses Google Maps API V3 (current, production version), which apparently does fancy things related to touch displays that conflict in some way with the JavaFX webview. Therefore, JavaFX and GMaps V3 don't play well together. It appears that this bug is fixed on JavaFX for Windows but not on JavaFX for Linux.
18-03-2013

There must be some problem with the demo itself since stock maps work fine in WebView. The only WebView problem I found was that Yahoo maps could not be dragged.
18-03-2013

Reopening since the demo is apparently still broken on Linux.
11-03-2013

Ok, I see... this bug may have been fixed on Windows but not other platforms? I just fired up an old Windows XP-64 machine, and it appears to work fine (I agree, resolved on windows). My environment is Linux x64. I tested it on: 8.0.0-ea-b78 ==> fails 2.2.7-b01 ==> fails I would suggest that this bug be re-opened and the platform set to Linux (since it is known to fail on JavaFX for Linux). I have not tested on Solaris, OSX, or any other platforms.
28-02-2013

https://code.google.com/p/gmaps-api-issues/issues/detail?id=4458#makechanges It should work with gmaps api v3.9 and higher. JavaFx 2.2.3 worked 100%.
28-02-2013

I am running JavaFX 8.0 bits with JDK 7u15. JDK 8 is not very stable at the moment.
28-02-2013

Are we sure this was resolved on Google's end? As far as I can tell, the WebMap is still broken. I attempt to drag the map (as per the bug report), and the map will not move (as per the bug report). I get a slightly different exception now, but I still get exceptions. Running on Java 8.
28-02-2013

The issue is no longer reproducible thanks to the fixes on the Google Maps side.
28-02-2013

The exception appears to no longer be reproducible in 8.0. The panning problem is still reproducible in 8.0. With the above changes, the panning problem is still reproducible. Are your observations different?
13-09-2012

Is it still reproducible in 8.0? Also it seems there is next workaround: webView.setOnDragDetected(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent t) { // intentionally do nothing } });
12-09-2012

Lowering priority of this issue as it represents a Google bug.
17-07-2012

Panning with mouse stopped working when we started building with ENABLE_TOUCH_EVENTS=1 as the result of RT-21052. It looks like the presence of 'ontouchstart' and other touch event handlers in the DOM causes Google Maps API to switch to some kind of a special mode in which mouse events are ignored. This looks like a bug in Google Maps. Interestingly, the issue is not reproducible with "standalone" Google Maps (maps.google.com), and Google Maps API v2. Yahoo and Bing maps do not have this issue either. I filed a bug against Google Maps: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4238 We could mitigate the issue by disabling touch events in WebKit at runtime if and when we know that the underlying platform does not provide touch events. The corresponding capability is present in WebKit, see RuntimeEnabledFeatures::setTouchEnabled, but works only for ports that use the V8 JavaScript engine, which is not the case for our port. As we seem to be unable to disable touch events at runtime, the only other option is to disable them at compile time, that is, revert RT-21052.
28-06-2012

Here is the trivial fix for a problem with crash (FX clipboard does not support an empty string as mime value): http://javaweb.us.oracle.com/jcg/fx-webrevs/RT-22914/1 But the problem with no-shearing context still exists. It is deeper that crash and needs to be investigated. Mouse shearing of map works without problems on goolge and yandex.
26-06-2012