GWT 2.7 Scheduler works different on mobile and desktop in SDM

115 views
Skip to first unread message

confile

unread,
Nov 25, 2014, 8:47:04 AM11/25/14
to google-web-tool...@googlegroups.com

It seems that the Scheduler works different on mobile and desktop when using SDM. 

I created a demo project (https://github.com/confile/GWT-2.7-Scheduler-Test) to show the problem.

This is a demo app to test how the GWT Scheduler works different on mobile and on desktop in Super Dev Mode.

I printed the height of a HTMLPanel for three different cases.

  1. right after the DOM elements are inserted into the page (GWTP onReveal())
  2. right after the DOM elements are inserted into the page and Scheduler with a deferred command is executed
  3. right after the DOM elements are inserted into the page and a Timer after 1000mx is fired

Here is the difference in the console output:

Output on Desktop

  • height before Timer and Scheduler: 0
  • height after Scheduler: 652
  • height after Timer: 652

Output on Mobile (iPhone 5, iOS 7.1.1)

  • height before Timer and Scheduler: 0
  • height after Scheduler: 425
  • height after Timer: 817

Jonathon Lamon

unread,
Nov 26, 2014, 10:11:01 AM11/26/14
to google-web-tool...@googlegroups.com
Timer and Scheduler.scheduleDeffered would not be expected to be equivalent.  They have two different semantics.  

Scheduler.scheduleDeffered - runs "after the browser event loop returns".
new Timer().schedule(1000) - runs 1000 ms after being scheduled.

You can not expect Scheduler.scheduleDeffered to give consistent results across platform.

Scheduler.scheduleFixedDelay would be more equivalent to Timer.schedule

confile

unread,
Nov 26, 2014, 11:45:35 AM11/26/14
to google-web-tool...@googlegroups.com
It is clear that Timer and Scheduler are different.

My concern is that Scheduler.scheduleDeffered behaves so differnent on different platforms. 

What is the best way to handle this?

Richard Wallis

unread,
Nov 26, 2014, 1:01:02 PM11/26/14
to google-web-tool...@googlegroups.com
@confile it is not possible to run your example because it is missing dependencies. 

From reading the code, the problem you are having is probably not caused by the Scheduler but by the time taken to resolve test.jpg.  After modifying an element it is not necessary to pause before calling getOffsetHeight(). The call itself will force a redraw and the value will not change over time unless the element itself changes.

In this case the height of the image element is changing as test.jpg downloads, this is why your output is inconsistent.


--
You received this message because you are subscribed to the Google Groups "GWT Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/93f92371-4bfe-42c3-a1c8-44390e3fb543%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

confile

unread,
Nov 26, 2014, 1:31:21 PM11/26/14
to google-web-tool...@googlegroups.com
Richard what do you suggest to solve this problem?
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit-contributors+unsubscribe@googlegroups.com.

Richard Wallis

unread,
Nov 26, 2014, 1:40:17 PM11/26/14
to google-web-tool...@googlegroups.com
Guessing but you can probably use image addLoadHandler() to wait for the image to load before checking the height.

A more complex alternative is to download the image using a getRequest and then transform it into a base64 dataUrl and use that as the src for your image.

To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/8bb121c7-2372-4419-86e7-993d9e992cd3%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages