Safari - can't run application because of dependencies

When the game is loaded I see error saying that

[Error] TypeError: null is not an object (evaluating 'req')
    getDB (SV.js, line 2766)
    getRemoteSet (SV.js, line 2824)
    (anonymous function) (SV.js, line 2747)
    getLocalSet (SV.js, line 2817)
    syncfs (SV.js, line 2745)
    (anonymous function) (SV.js, line 3714)
    forEach ([native code], line 0)
    syncfs (SV.js, line 3710)
    (anonymous function) (SV.js, line 8)
    (anonymous function) (SV.js, line 12)
    callRuntimeCallbacks (SV.js, line 1066)
    preRun (SV.js, line 1095)
    run (SV.js, line 3255225)
    runCaller (SV.js, line 3255178)
    removeRunDependency (SV.js, line 1293)
    (anonymous function) (SV.js, line 11020)
    xhr_onload (SV.js, line 11008)

I think that this error comes from this code in generated javascript file:

var req;
  try {
   req = IDBFS.indexedDB().open(name, IDBFS.DB_VERSION);
  } catch (e) {
   return callback(e);
  }
  req.onupgradeneeded = (function(e) { ... }
  // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

So I checked console again and found another error that might explain things:

[Error] run() called, but dependencies remain, so not running
still waiting on run dependencies:
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!

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?

Hm. That’s strange. I am running Safari Version 8.0.7 (10600.7.11.0.1).

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

Unzipping my jsgz file found this →

        var req;
        try {
            req = IDBFS.indexedDB().open(name, IDBFS.DB_VERSION)
        } catch (e) {
            return callback(e)
        }

Need help for this please.
One more thing this is only happening on Safari in a Private Window.

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:

  var Module = {
    TOTAL_MEMORY: 268435456,
    errorhandler: null,            // arguments: err, url, line. This function must return 'true' if the error is handled, otherwise 'false'
    compatibilitycheck: function() {
      if (browser.indexOf("Safari") != -1) {
        var db;
        try { db = window.indexedDB.open("/idbfs-test"); db.onsuccess = function() { db.result.close() }; } catch (e) {}
        if (!db)
          window.indexedDB = window.mozIndexedDB = window.webkitIndexedDB = window.msIndexedDB = false;
      }
      CompatibilityCheck();
    },
    dataUrl: "Release/mygame.data",
    codeUrl: "Release/mygame.js",
    memUrl: "Release/mygame.mem",
  };

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.

1 Like

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!