Polymer - Don't load app until geolocation isn't set - polymer

I'm currently working on a webapp with the polymer-framework.
However, the whole application depends on the geolocation of the device. I'm setting the location in the app-globals file to use it globally, but it takes some time (around 500ms).
My question now is, how can I say to polymer that it should get to work, after the geolocation is set?
Thanks!

I think it depends on the specific behavior you're looking for. A few cases:
Everything still loads when the page loads, including perhaps some app UI and you have a loading icon or similar to indicate that the app is still starting up while you're waiting for the location.
You don't want to show the app until you have the location. Perhaps you don't want the app resources to be loaded at this time either.
You don't even want Polymer to be loaded until you have the location.
There's a lot of options & they may depend on your app architecture a bit, but for a general structure:
show a loader icon on startup & just wait to populate any templates you have until location is set
perhaps keep the hidden attribute on your main app element until location is available &/or don't append the element to the DOM until this point (although with similar resource loading opportunity caveat as in 3 below).
you could wait to add polymer & related elements until location is available, but generally seems silly to do this since your app could be doing this work while the user is waiting for a location to be found.
If you've got a more specific need then more details are probably needed.

Related

Viewer quality settings (for one viewer on the page)

I have two viewers on the same page. And I want to set performance settings for only one viewer with following code:
this.viewer.setQualityLevel(false, false);
this.viewer.setGroundShadow(false);
this.viewer.setGroundReflection(false);
this.viewer.setProgressiveRendering(true);
BUT (!) settings are applied for both viewers for some reason. Is there any way to apply them only for one viewer on the page?
The viewer settings are kept in localStorage, so changing them using methods like viewer.setQualityLevel probably propagates the updates to other viewer instances as well. Let me discuss this behavior with the dev team as (I think) it could be considered a bug.
In the meantime, if you need to change settings for a single instance of the viewer, consider using "lower level" methods that don't use the local storage. For example, instead of viewer.setQualityLevel(useSAO, useFXAA) you could use viewer.impl.togglePostProcess(useSAO, useFXAA), and instead of viewer.setGroundShadow(bool) you could use viewer.impl.toggleGroundShadow(bool).
EDIT
Also try the Profile API to persist settings - you can get the current profile with:
viewer.profile
I was unable to replicate the issue unfortunately ... looking at your code did you assign two viewers to the same handle? can you post your code to initialize viewers? what version of viewer btw?

Application Cache - HTML 5

In one of the online documents that talks about appcache for HTML5, it indicates that the cached files get updated once an offline user reconnects. I checked the original HTML5 appcache definition by W3, and I am not able to find anything that supports this statement.
Does anyone know if this is to be true?
Thanks in advance
MDN says the following, although if you scroll up on that page it says it's being deprecated.
If an application cache exists, the browser loads the document and its associated resources directly from the cache, without accessing the network. This speeds up the document load time.
The browser then checks to see if the cache manifest has been updated on the server.
If the cache manifest has been updated, the browser downloads a new version of the manifest and the resources listed in the manifest. This is done in the background and does not affect performance significantly.
And logic tells me that it would also depend on the app you're using, server you're trying to connect to and any special settings it might have, how long your browser keeps it's history, what it keeps, and if you saved the page to view offline - whether or not you have all the code/images saved in the right location(s).
Example:
Imagine you saved a page to view offline, and that page has a JS event handler that ran a while loop that did an ajax request every n seconds to do something, like make a number on a page change as long as you were online... As long as the loop is running, you suddenly connect to the internet, and it makes the request to the proper url with the right arguments, then it should go through, even though the url in your browser might say something like file:///C:/Users/you/Desktop/....
I've done this before, even though my url was like the one above. One time I was using braintree's drop-in javascript to a website, and using it's api on my backend. Trying to load the page when offline = Nothing. Online = Updated the spot on the page just fine when I had the required arguments, and it was pointing to the right url. If I got offline again, I could refresh the page, see the same images loaded in the <div>, but I couldn't send any data with it.

Google Web Designer has a very long load time

I'm creating an html5 banner using Google Web Designer. I've created the banner and published it. When I view the published version I noticed that it takes sometime to load.
Someone else on my team is also creating HTML5 banners. The banner that he creates loads instantly even though its a larger file size. We compared our files and other than the actual assets, the way the banner was created and published is the same.
Does anyone have any ideas why this might be happening?
GWD add this code at the end of the banner and animation show up immediately:
<script data-exports-type="dclk-quick-preview">studio.Enabler.setRushSimulatedLocalEvents(true);</script>
Which environment are you using?
When creating a new project in GWD you are able to select an environment. By default is DoubleClick.
This adds additional file (in the case of DoubleClick, the Enabler library).
If you open your Chrome console, while running the banner, you will see that the banner is not initialized until the enabler is available.
You will also see how much time it takes to load the enabler.
If your colleague is creating a banner without that library, or without correctly listening to the event Enabler.initialized, this may be the main reason for the discrepancy.
If you don't want to include this additional library (that is used to integrate your banner in DoubleClick Studio), just select Generic from the environments dropdown.
There is also another reason that may cause the delay, and is the PoliteLoader.
You can select to politeLoad the banner from the Publish menu.
If the PoliteLoader is selected this cause the banner to be initialized only after the page is fully loaded. This may cause delays compared to a non polite loaded ads.
This all seems not to be a bug, but a feature of enabler.js simulates a test environment, when not beeing uploaded to Adwords (guess it similar in Doubleclick). Uploading to Google Environments should change the situation
Look at the console and see:
There is a long delay in alle items loading after the enabler.js.
It is NOT because of a long loading time of enabler.js - thats all fine.
Looking at the Logs, the enabler waits a second and throws out:
[ 1.008s] [studio.sdk] Using default ad parameters in test environment. Simulating local events.
When uploading to Google Adwords (i assume that this all is similar to DC Studio) - the enabler throws out different logs and the delay disappears.
Hope this was helpful.
By chance, I found out a way to make the Enabler loading fast. Instead of using Publish, use Preview to generate the HTML.
For some reasons, Enabler.js in preview-generated HTML only takes 0.019s to load as compared to Enabler.js in publish-generated HTML taking 1.015s to load.
Studio Enabler SDK looks for "e" parameter in iframe URL containing Studio creative. It expects a number and uses that to set the creative environment.
Setting e=1 in your preview environment (query string parameter in the iframe url pointing at the index.html for your studio creative) will tell Enabler to use LIVE mode.
I assume there is a reason why Enabler has this functionality (avoid counting impressions or paying for impressions from test/qa environment)...so I wouldn't suggest using this as a permanent setting.

How do you change source in a web audio context

I'm making a game that changes some of it's object depending on what music is playing. After each song has ended I want my audio context to load in a new source and analyze that. However whenever I tried to do that I've gotten the error that an audio object or buffer can't be called twice.
After some researching I learned that ctx.createMediaElementSource(MyHTML5AudioEl) lets you create a sourceNode that takes the source from a HTML5 object. With this I was able to loop through different song.
However for my game I need to play/analyze a 30 seconds "remote url" that comes out of the Spotify API. I might be wrong but ctx.createMediaElementSource(MyHTML5AudioEl)does not allow you to analyze a source that is on a remote site.
Also the game needs to work on Mobile Chrome, which createMediaElementSource(MyHTML5AudioEl) does not seem to work on.
I might be on the completely wrong path here but my main question is:
How can I switch remote songs urls in web audio api. With it being compatible with mobile chrome.
Thanks!
First, as you found out, you can't set the buffer again for an AudioBufferSource. The solution is to create a new one. AudioBufferSources are intended to be light-weight objects that you can easily create and use.
Second, in Chrome 42 and newer, createMediaElementSource requires appropriate CORS access so you have to make sure the remote url sends the appropriate headers and you set the crossOrigin attribute appropriately.
Finally, Mobile Chrome currently does not pass the data from an audio element through createMediaElementSource.

How to serialize/deserialize Chrome tab (its DOM/RenderTree))?

How to serialize a complete process?
In specially if the process is a Chrome's tab (with its rendered DOM). Is it possible to completely serialize Chrome tab/(tab's DOM) and then to deserialize it again? So that the tab do not need to request HTML via HTTP(S) from the tab's URL again and also do not need to build DOM in the RAM, but instead, just load the DOM and send to render (to OS/GPU?).
Update:
I know, that it looks inefficiently (i.e. each tab process takes about 80 mb of RAM and so much more in a serialized form), but still it is interesting if it is possible to achieve? Hypothetical application: fine-grained serialization of a web-application to the disk and restore it afterwards like it would not (possibly except session tokens) be closed
Update2:
I have just found a thread about the idea behind the question: http://mac-os-forge.2317878.n4.nabble.com/DOM-Serialization-td173772.html . But there is no result in the end of discussion (just somebody found this impractical). The thread is from 2010.
Update3:
there is a question similar to this (just related to iOS app, still about Web View serialization): UIWebView serialization after content has been rendered . Still no solution.
Update4:
Somebody tells about
DOM Level 3 defines Load & Save interface of DOM
http://marc.info/?l=webkit-dev&m=126432160427677
is it something related to save and load the rendered DOM memory model?
Update5:
here [Rendering in Webkit (2009): https://www.youtube.com/watch?v=RVnARGhhs9w] the guy talks about different trees appearing while rendering process (Source Text -> DOM Tree -> RenderObject tree -> RenderStyles -> LineBoxes/Layers). So is it possible to serialize the last structures (RenderStyles -> LineBoxes/Layers) and recreate only them when restoring the tab, not the complete rendering process again? As possible application I find the "Duplicate Tab" command implementation: now it works in the way of rendering from the beginning on the complete page again (from the URL loading). It would be also nice that "Duplicating Tab" would just clone the data structures and re-render only the graphics, not the data structures themselves.
Update6:
this question is very similar: How to save a tab's memory state in Firefox/Chrome?
Update7:
would "process migration" be something reasonable for the solution?
Extracted from http://www.chromium.org/developers/design-documents/oop-iframes/oop-iframes-rendering#TOC-Background
"As each node is added to the DOM tree, the attach() method is called on it which creates an associated renderer "
So you will always need to recreate the DOM in RAM since it is not used as input to a previously existing renderer but also triggers render/s creation.