Hybrid View

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Feb 2013
    Posts
    3
    Vote Rating
    1
    SimonTheSorcerer is on a distinguished road

      0  

    Default Issues with the microloader and OpenLayers and other scripts

    Issues with the microloader and OpenLayers and other scripts


    Hello! I've run into an issue that I have figured out, but still not quite resolved.

    Our Sencha Touch+OpenLayers application was working fine during development, but the optimized release build failed because OpenLayers could no longer be found. It was as if it never had been loaded, even though I could clearly see it being downloaded. The debugger in Chrome reported several errors like "OpenLayers is not defined".

    After much head scratching I had to investigate what the microloader was doing in the production build. It does an "eval" on each javascript asset defined in app.json (OpenLayers was one of them), in a function called "evaluateAsset". This evaluates the scripts in the local scope of evaluteAsset. This means that any script that introduces new bindings with "var = ..." will not work correctly, because they will be lost when the function returns. This was the case with OpenLayers and Proj4JS in our case.

    I thought this was a very subtle and hard error to track down. It's particularly annoying because during development this is not an issue, because the javascript assets are loaded differently. A working solution for us was to remove the "var" bit from the offending libraries. I'm wondering if the microloader should instead try to evaluate the assets in the global scope? Particularly because otherwise we have these differences with development vs. production.
    Last edited by SimonTheSorcerer; 6 Feb 2013 at 3:45 AM. Reason: typo

  2. #2
    Sencha Premium Member
    Join Date
    May 2011
    Posts
    71
    Vote Rating
    6
    cyee is on a distinguished road

      0  

    Default


    Have you tried changing the production microloader so it does an indirect global eval?

  3. #3
    Sencha User
    Join Date
    Feb 2013
    Posts
    3
    Vote Rating
    1
    SimonTheSorcerer is on a distinguished road

      1  

    Default


    Yes, and it seems to be working. And I have yet to notice any adverse effects, nor did I expect any, but the subtleties of this language makes me a bit cautious To clarify, I have change the eval-line in the microloader to read like this:
    Code:
     (42,eval)(asset.content);
    I can't claim to understand why you have resort to this trick to make a global eval, but there it is. I think the microloader should be doing this, don't you?

  4. #4
    Sencha Premium Member
    Join Date
    May 2011
    Posts
    71
    Vote Rating
    6
    cyee is on a distinguished road

      0  

    Default


    Agreed, since it's pointless to eval the loaded assets in a temporary context

  5. #5
    Sencha User semiaddict's Avatar
    Join Date
    Mar 2010
    Posts
    45
    Vote Rating
    2
    semiaddict is on a distinguished road

      0  

    Default


    @SimonTheSorcerer, thank you, this saved my day.

    I'm not sure I understand what the "(42, eval)" does, but it works great.
    ---
    Oussama Mubarak // Semiaddict

  6. #6
    Sencha User
    Join Date
    Feb 2013
    Posts
    3
    Vote Rating
    1
    SimonTheSorcerer is on a distinguished road

      0  

    Default


    Quote Originally Posted by semiaddict View Post
    I'm not sure I understand what the "(42, eval)" does, but it works great.
    When eval is called directly, like eval(asset.content), the evaluation is done in the local scope. So any local bindings introduced will be lost when the function returns. When eval is called indirectly, it makes a global eval. The value of the expression (a,b) is b, or in this case eval. The 42 is not relevant, we just want to call eval without using the name directly.

    That's how I understand it, anyway. I'm glad it helped someone else.

Thread Participants: 2

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi