Generate user.agent independent code

139 views
Skip to first unread message

Philipp

unread,
Nov 30, 2018, 9:13:53 AM11/30/18
to GWT Users
I'm interested in compiling my GWT code unaware of any user.agent. When removing the user.agent property from the xml GWT compiles 5 permutations but I would actually like just one (for Safari, Firefox, Chrome, Edge). I can for example set the user.agent to Safari, compile it and it runs (apparently) perfectly fine in Firefox but of course I get the severe warning that: "Possible problem with your *.gwt.xml module file."

So my question is two fold:
  • Can I create just one permutation without getting a warning when loading the file
  • How could I check where GWT creates different JavaScript code for different browsers to find possible issues when just using one permutation for the listed browsers.
If it helps:
  • I'm not using any GUI functionality from GWT. Basically GWT is only glue code between TypeScript and a WebAssembly API.
  • The whole project consists of 2 GWT Projects, where one will launch a native javascript web worker which loads the 2nd GWT project.

Lars

unread,
Nov 30, 2018, 3:16:45 PM11/30/18
to GWT Users

Philipp

unread,
Nov 30, 2018, 3:43:41 PM11/30/18
to GWT Users
Perfect, thanks!

Jens

unread,
Nov 30, 2018, 3:46:58 PM11/30/18
to GWT Users
If you are just using GWT JRE emulation then I think you could just only inherit Core.gwt.xml from GWT SDK. That should not give you user agent based permutation. The JRE emulation does not use deferred binding based on user agent.

Once you only have a single permutation you can use the single script linker by using <add-linker name="sso" /> in your GWT module. Then you should have just a single js file as out

-- J.

Philipp Gloor

unread,
Dec 7, 2018, 8:47:35 AM12/7/18
to google-we...@googlegroups.com
OK, I just realized that this somehow only worked for Firefox.

Maybe I have to explain the project structure a bit more. I have 5 projects of which I compile 2 and they depend on the others. It doesn't matter whether I put <collapse-all-properties/> in just the main projects or in all of them. The problem remains the same:

When trying to load then the nocache files it fails on the file that nocache is supposed to load.

Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'http://localhost:4400/pdfwebviewer/webworker/0CBE8FF2A030D479B8A35F1BF1905C26:4.cache.js' failed to load.

As you can see there is this :4.cache.js

The code from the nocache looks like this:

function importScriptFromBase(){
  var $intern_0 = 'gecko1_8', $intern_1 = '0CBE8FF2A030D479B8A35F1BF1905C26', $intern_2 = 'ie10', $intern_3 = ':1', $intern_4 = 'ie8', $intern_5 = ':2', $intern_6 = 'ie9', $intern_7 = ':3', $intern_8 = 'safari', $intern_9 = ':4', $intern_10 = 'user.agent', $intern_11 = '.cache.js', $intern_12 = 'webworker', $intern_13 = '';
  var strongName;
  try {
    unflattenKeylistIntoAnswers([$intern_0], $intern_1);
    unflattenKeylistIntoAnswers([$intern_2], $intern_1 + $intern_3);
    unflattenKeylistIntoAnswers([$intern_4], $intern_1 + $intern_5);
    unflattenKeylistIntoAnswers([$intern_6], $intern_1 + $intern_7);
    unflattenKeylistIntoAnswers([$intern_8], $intern_1 + $intern_9);
    strongName = answers[computePropValue($intern_10)];
  }
   catch (e) {
    return;
  }
  var url_0 = strongName + $intern_11;
  importScripts(url_0);
  gwtOnLoad(undefined, $intern_12, $intern_13);
}

So for gecko1_8 this works fine but tries to load the cache file with a weird ending. Any hints on this?

On Fri, 30 Nov 2018 at 21:17, Lars <lars.gem...@gmail.com> wrote:
--
You received this message because you are subscribed to a topic in the Google Groups "GWT Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-web-toolkit/qyF5It-UR94/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-web-tool...@googlegroups.com.
To post to this group, send email to google-we...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Kirill Prazdnikov

unread,
Dec 21, 2018, 7:16:08 AM12/21/18
to GWT Users
I prefer to select the one single permutation: <set-property name="user.agent" value="safari"/>

Reply all
Reply to author
Forward
0 new messages