Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Safari - can't run application because of dependencies

Discussion in 'Web' started by d12frosted, Jun 25, 2015.

  1. d12frosted

    d12frosted

    Joined:
    Feb 3, 2014
    Posts:
    43
    When the game is loaded I see error saying that

    Code (JavaScript):
    1. [Error] TypeError: null is not an object (evaluating 'req')
    2.     getDB (SV.js, line 2766)
    3.     getRemoteSet (SV.js, line 2824)
    4.     (anonymous function) (SV.js, line 2747)
    5.     getLocalSet (SV.js, line 2817)
    6.     syncfs (SV.js, line 2745)
    7.     (anonymous function) (SV.js, line 3714)
    8.     forEach ([native code], line 0)
    9.     syncfs (SV.js, line 3710)
    10.     (anonymous function) (SV.js, line 8)
    11.     (anonymous function) (SV.js, line 12)
    12.     callRuntimeCallbacks (SV.js, line 1066)
    13.     preRun (SV.js, line 1095)
    14.     run (SV.js, line 3255225)
    15.     runCaller (SV.js, line 3255178)
    16.     removeRunDependency (SV.js, line 1293)
    17.     (anonymous function) (SV.js, line 11020)
    18.     xhr_onload (SV.js, line 11008)
    I think that this error comes from this code in generated javascript file:

    Code (JavaScript):
    1. var req;
    2.   try {
    3.    req = IDBFS.indexedDB().open(name, IDBFS.DB_VERSION);
    4.   } catch (e) {
    5.    return callback(e);
    6.   }
    7.   req.onupgradeneeded = (function(e) { ... }
    8.   // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    9.  
    So I checked console again and found another error that might explain things:

    Code (JavaScript):
    1. [Error] run() called, but dependencies remain, so not running
    Code (JavaScript):
    1. still waiting on run dependencies:
    2. dependency: JS_FileSystem_Mount
    I know that FireFox is the browser that is supported. But previously I was able to run our game in Safari, and now I am not because of this error. I am building using Unity 5.1.0p1 on OS X 10.10.4 (14E36b).

    Do you have any clues?
    Thanks in advance!
     
  2. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    This looks like some issue initializing the IndexedDB we use for local storage (PlayerPrefs, Cache, etc). Safari used to not support this until version 8, which would then result in similar errors. But in Safari 8, this should work (and does for me), so I'm not sure why you are seeing this error? I am still on 10.10.4 with Safari 8.0.6, wonder if anything changed here?
     
  3. d12frosted

    d12frosted

    Joined:
    Feb 3, 2014
    Posts:
    43
    Hm. That's strange. I am running Safari Version 8.0.7 (10600.7.11.0.1).
     
  4. wahnishjorge25

    wahnishjorge25

    Joined:
    Jan 24, 2015
    Posts:
    13
    Not using Data Caching (the option on the build) or Player Prefs, any other solution for this? Happening on Safari version 9 and my Unity Version is 5.3.3f1
     
  5. wahnishjorge25

    wahnishjorge25

    Joined:
    Jan 24, 2015
    Posts:
    13
    Unzipping my jsgz file found this ->

    Code (JavaScript):
    1.         var req;
    2.         try {
    3.             req = IDBFS.indexedDB().open(name, IDBFS.DB_VERSION)
    4.         } catch (e) {
    5.             return callback(e)
    6.         }
    Need help for this please.
    One more thing this is only happening on Safari in a Private Window.
     
  6. alexsuvorov

    alexsuvorov

    Unity Technologies

    Joined:
    Nov 15, 2015
    Posts:
    327
    Hello wahnishjorge25.

    This issue has been already resolved and the fix will be available in future patches/release. For now you may use the following workaround:

    Add the following compatibilitycheck handler to your Module in the index.html:
    Code (JavaScript):
    1.   var Module = {
    2.     TOTAL_MEMORY: 268435456,
    3.     errorhandler: null,            // arguments: err, url, line. This function must return 'true' if the error is handled, otherwise 'false'
    4.     compatibilitycheck: function() {
    5.       if (browser.indexOf("Safari") != -1) {
    6.         var db;
    7.         try { db = window.indexedDB.open("/idbfs-test"); db.onsuccess = function() { db.result.close() }; } catch (e) {}
    8.         if (!db)
    9.           window.indexedDB = window.mozIndexedDB = window.webkitIndexedDB = window.msIndexedDB = false;
    10.       }
    11.       CompatibilityCheck();
    12.     },
    13.     dataUrl: "Release/mygame.data",
    14.     codeUrl: "Release/mygame.js",
    15.     memUrl: "Release/mygame.mem",
    16.   };
    You can also add this using template so that it will be added to each build automatically. Let me know if you need any help with this or if this workaround does not cover your use case. Note that access to the indexedDB is restricted from a private Safari window so PlayerPrefs will not be saved.
     
    Last edited: Apr 6, 2016
    wahnishjorge25 likes this.
  7. wahnishjorge25

    wahnishjorge25

    Joined:
    Jan 24, 2015
    Posts:
    13

    Thanks for the quick response alex, later on the day I will try the compatibility, Im not using PlayerPrefs so there's no problem with that.
    Talk you later!