MethodAccessException in WebPlayer

I get an exception when calling ScanLoop, but only on the webPlayer built using 4.6.3f1 and a* version 3.6.4

It’s a recast graph ca. 4k,1,4k cell:20 tile:20, 4 threads, no penalties, no zip, no gui

    OnScanStatus info = delegate(Progress p) {
        OnCheckForReadyProgress(Mathf.Lerp(0.2f, 0.7f, p.progress), GUIString.LoadingNavigation);
        Console.WriteLine("Scanning:" + p.description + " " + p.progress);
        //Debug.Log("Scanning:" + p.description + " " + p.progress);


MethodAccessException: Attempt to access a private/protected method failed.
  at System.Security.SecurityManager.ThrowException (System.Exception ex) [0x00000] in <filename unknown>:0 
  at Pathfinding.ThreadControlQueue.get_AllReceiversBlocked () [0x00000] in <filename unknown>:0 
  at AstarPath.BlockUntilPathQueueBlocked () [0x00000] in <filename unknown>:0 
  at Pathfinding.AstarData.DeserializeGraphs (System.Byte[] bytes) [0x00000] in <filename unknown>:0 
  at Pathfinding.AstarData.DeserializeGraphs () [0x00000] in <filename unknown>:0 
  at Pathfinding.AstarData.Awake () [0x00000] in <filename unknown>:0 
  at AstarPath.Initialize () [0x00000] in <filename unknown>:0 
  at AstarPath.Awake () [0x00000] in <filename unknown>:0 

Leads to this code:

	/** True if blocking and all receivers are waiting for unblocking */
	public bool AllReceiversBlocked {
		get {
			lock (lockObj) {
				return blocked && Thread.VolatileRead (ref blockedReceivers) == numReceivers;

Tried so far with no effect.

  • Changing thread count to none has
  • Changing blockedReceivers to internal
  • Changing save/load/caching
  • Tried removing GO and dragging in prefab from new

It seems that I have got some beta code going and reverting the code back to 3.6 fixes everything, looking at the newest beta version now.

return blocked && blockedReceivers == numReceivers;

Ah. It seems Thread.VolatileRead is not available in the webplayer. Should have checked that.

Now the question is… Why did I add that code. All accesses are done inside locks… It is possible that it is just debugging code and I forgot to remove it…

Does it have to do with CPU’s write-buffer flushing their writes?
I found this which seems to be a good read but don’t have the office time to go deep

but I honestly don’t know how much carries to mono

I’m getting this too on the webplayer of unity5 with your latest beta version (3.6.7?). You said the code is actually not necessary, do you have a quick workaround? is it safe to comment out the sleep around lines 1892?


As far as I can see, it should be safe to change

return blocked && Thread.VolatileRead (ref blockedReceivers) == numReceivers;


return blocked && blockedReceivers == numReceivers;

The reason why the error occurs is because the version of .net that unity uses in the webplayer does not have support for VolatileRead.

1 Like