Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random asset load order in Safari causing runtime bugs #13

Open
drnic opened this issue Jul 2, 2009 · 12 comments
Open

Random asset load order in Safari causing runtime bugs #13

drnic opened this issue Jul 2, 2009 · 12 comments

Comments

@drnic
Copy link

drnic commented Jul 2, 2009

In Safari 4.0.1, the generated <script> tags are correct, but Safari is loading the various assets in non-deterministic order; that is, random. So in running tests sometimes they don't run at all because jQuery or screw.builder hasn't been loaded yet.

application.html - random load order causes issues
Uploaded with plasq's Skitch!
random load order causing issues
Uploaded with plasq's Skitch!
@karnowski
Copy link

Dr Nic, thanks for pointing this out. It looks like we need to explicitly chain the requires in the blue-ridge.js file rather than just require them all asynchronously.

@tanzeeb
Copy link

tanzeeb commented Jul 10, 2009

Hi,

I reordered the require's in blue-ridge.js like so:

require(BLUE_RIDGE_LIB_PREFIX + "jquery-1.3.2.js", { onload: function() {
    require(BLUE_RIDGE_LIB_PREFIX + "jquery.fn.js", { onload: function() {
        require(BLUE_RIDGE_LIB_PREFIX + "jquery.print.js", { onload: function() {
            require(BLUE_RIDGE_LIB_PREFIX + "screw.builder.js", { onload: function() {
                require(BLUE_RIDGE_LIB_PREFIX + "screw.matchers.js", { onload: function() {
                    require(BLUE_RIDGE_LIB_PREFIX + "screw.events.js", { onload: function() {
                        require(BLUE_RIDGE_LIB_PREFIX + "screw.behaviors.js", { onload: function() {
                            require(BLUE_RIDGE_LIB_PREFIX + "smoke.core.js", { onload: function() {
                                require(BLUE_RIDGE_LIB_PREFIX + "smoke.mock.js", { onload: function() {
                                    require(BLUE_RIDGE_LIB_PREFIX + "smoke.stub.js", { onload: function() {
                                        require(BLUE_RIDGE_LIB_PREFIX + "screw.mocking.js", { onload: function() {
                                            require(derive_spec_name_from_current_file());
                                        }});
                                    }});
                                }});
                            }});
                        }});
                    }});
                }});
            }});
        }});
    }});    
}});

Everything loads in order, but it tests still don't run correctly on Safari 4. Any ideas?

@drnic
Copy link
Author

drnic commented Jul 10, 2009

Let's just take a moment to observe how disturbing that code looks due to the nested nature. ... I need another moment... :D

If we do get this working, it would be fun to come up with a DSL for nested require's, something like:

   require('some_file.js').
   then_require('dependent_file.js)

That would be sweet.

Are you coming to FutureRuby this weekend?

@karnowski
Copy link

@tanzeeb: Have you actually got it working with that? When I make that change, the files load correctly, but Safari 4.0.2 doesn't actually run any of the tests.

It looks like Safari either 1) isn't telling jQuery that the DOM is ready or 2) telling jQuery that the DOM is ready too soon.

@drnic
Copy link
Author

drnic commented Jul 10, 2009

@karnowski - @tanzeeb says above it still isn't working for him on Safari.

Hmm, interesting problem. I'm sure I've seen the tests run occasionally on Safari. Hopefully I can find some time to poke around. Stupid bug.

@karnowski
Copy link

Ah, so he does! Thanks @drnic.

@tanzeeb
Copy link

tanzeeb commented Jul 14, 2009

@drnic Well if you rotate your monitor 90 degrees, it looks like a very nice pyramid. ;-) Missed out on FutureRuby, did you go? How was it?

@karnowski No I still haven't figured out why it doesn't run in Safari 4. Tight deadline on my project, but once its done I'll take a look to see why. I think you're right about it being a jQuery / DOM Ready issue.

@wireframe
Copy link

any updates?

I'm stuck with a safari specific bug and I'd love to write some tests to verify the bugs are fixed.

@karnowski
Copy link

Updates: We can use tazeeb's fix above, but then we're still stuck with the Safari-4 problem described in issue #21. I'm leaving this issue open to add tanzeeb's fix (but with a more fluent interface on require).

@ndp
Copy link

ndp commented Apr 2, 2010

I/we are nearly there with a fix to this. See my "safari" branch for current code. It's not ready yet, but close. A few things of note:
(1) there was an extra slash in the paths, causing scripts not to be loaded
(2) safari/chrome seem to cache local files mercilessly. The only way I was able to see changes was to restart chrome with each change. Ugh. I put in an alert and changed it so I could see changes. Quite tedious.
(3) My approach to the "require" problem is this: "require" collects all needed files into an array (but doesn't include them). There's a final process call that pulls them off one at a time, creating an onload handler.
(4) screw unit still tries to start up before it's ready. By removing this from the screw builder file and calling it after all the onloads have run, it seems to run reliably.

This has broken existing tests, so I'll have to sort that out.

@ndp
Copy link

ndp commented Apr 3, 2010

See my pull request.

@jonah-williams
Copy link

I'm running tests in multiple browsers using ndp's branch. I think this is a great improvement and fixes two open issues.
Karnowski can you pull these changes into the relevance branch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants