Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by pixelord · Apr 07, 2020 at 07:48 AM · pluginnative pluginthreading

Accessing Native plugin from a thread.

I am trying to build a native plugin that would process a rendertexture in C++ code. My C# script creates a thread and I call the native plugin function from that thread.

         lock(thisLock)
         {
             this.textureData = screenShot.GetRawTextureData();
             //SetRenderTextureFromUnity(this.textureData, this.textureData.Length);
             Debug.Log(string.Format("Rawtexture size {0}", textureData.Length));
         }
   
          new System.Threading.Thread(() =>
          {
              lock(thisLock)
              {
                  SetRenderTextureFromUnity(this.textureData, this.textureData.Length);
                  Debug.Log("Writing to shared memory");
              }
             
          }).Start();

The problem is this code works in editor but after I build it, the player crashed. I did some testing, and it looks like, if I call the plugin from main thread, it works fine. Liek below:

             this.textureData = screenShot.GetRawTextureData();
             SetRenderTextureFromUnity(this.textureData, this.textureData.Length);
             Debug.Log(string.Format("Rawtexture size {0}", textureData.Length));
      

I inevstigated my crash report, and it shows this error: (Last few line of the error dump is quite interesting. Can anyone give me an idea, what might be going on?)

 TracerRenderer by Unity Technologies [version: Unity 2018.4.15f1_13f5a1bf9ca1]
 
 UnityPlayer.dll caused an Access Violation (0xc0000005)
   in module UnityPlayer.dll at 0033:39b8e879.
 
 Error occurred at 2020-04-07_100058.
 E:\Development\BoxerUnityBuild\TracerRenderer.exe, run by SimMachine01.
 
 23% physical memory in use.
 32572 MB physical memory [25051 MB free].
 462 MB process peak paging file [462 MB used].
 272 MB process peak working set [272 MB used].
 System Commit Total/Limit/Peak: 9499MB/42300MB/9933MB
 System Physical Total/Available: 32572MB/25051MB
 System Process Count: 264
 System Thread Count: 3344
 System Handle Count: 99209
 Disk space data for 'C:\Users\SIMMAC~1\AppData\Local\Temp\Unity Technologies\TracerRenderer\Crashes\Crash_2020-04-07_000057511\': 52294942720 bytes free of 255266385920 total.
 
 Read from location 0000000000000000 caused an access violation.
 
 Context:
 RDI:    0x00007ffda3b10000  RSI: 0x00000215186f4148  RAX:   0x0000000000000000
 RBX:    0x00000215186e7301  RCX: 0x0000000000000000  RDX:   0x0000000000000000
 RIP:    0x00007ffd39b8e879  RBP: 0x000000abcc6fc910  SegCs: 0x0000000000000033
 EFlags: 0x0000000000010202  RSP: 0x000000abcc6fc6f0  SegSs: 0x000000000000002b
 R8:     0x0000000000000000  R9:  0x00007ffd39380000  R10:   0x0000000000000000
 R11:    0x00000215186f4100  R12: 0x000000abcc6fd9a0  R13:   0x000002152bfbe860
 R14:    0x000000abcc6fc7c0  R15: 0x0000000000000000
 
 
 Bytes at CS:EIP:
 48 8b 10 ff 92 68 05 00 00 eb 02 32 db e8 a5 42 
 
 Mono DLL loaded successfully at 'E:\Development\BoxerUnityBuild\MonoBleedingEdge\EmbedRuntime\mono-2.0-bdwgc.dll'.
 
 
 Stack Trace of Crashed Thread 6976:
 0x00007FFD39B8E879 (UnityPlayer) UnityMain
 0x00007FFD39B8D4CA (UnityPlayer) UnityMain
 0x00007FFD4A931B27 (mono-2.0-bdwgc) mono_lookup_pinvoke_call
 0x00007FFD4A944466 (mono-2.0-bdwgc) mono_install_ftnptr_eh_callback
 0x00007FFD4AA19E92 (mono-2.0-bdwgc) mono_set_defaults
 0x00007FFD4A9E1C79 (mono-2.0-bdwgc) mono_unity_unlock_dynamic_function_access_tables64
 0x00007FFD4A9E6841 (mono-2.0-bdwgc) mono_unity_unlock_dynamic_function_access_tables64
 0x00007FFD4A9EAC62 (mono-2.0-bdwgc) mono_get_runtime_build_info
 0x00007FFD4AAC6EBC (mono-2.0-bdwgc) mono_unity_backtrace_from_context
 0x0000021518451073 (Mono JIT Code) <unknown class>.<unknown method>()
 0x0000021531AC15D6 (mscorlib) System.Threading.ThreadHelper.ThreadStart_Context()
 0x0000021531AC0FDE (mscorlib) System.Threading.ExecutionContext.RunInternal()
 0x0000021531AC0D2B (mscorlib) System.Threading.ExecutionContext.Run()
 0x0000021531AC0B3B (mscorlib) System.Threading.ExecutionContext.Run()
 0x0000021531AC0953 (mscorlib) System.Threading.ThreadHelper.ThreadStart()
 0x0000021531AC08B4 (mscorlib) System.Object.runtime_invoke_void__this__()
 0x00007FFD4A9EB7B0 (mono-2.0-bdwgc) mono_get_runtime_build_info
 0x00007FFD4A971892 (mono-2.0-bdwgc) mono_perfcounters_init
 0x00007FFD4A97AA62 (mono-2.0-bdwgc) mono_runtime_invoke_array
 0x00007FFD4A994CFF (mono-2.0-bdwgc) mono_threads_set_shutting_down
 0x00007FFD4A994A46 (mono-2.0-bdwgc) mono_threads_set_shutting_down
 0x00007FFDAF8E7BD4 (KERNEL32) BaseThreadInitThunk
 0x00007FFDAFC4CED1 (ntdll) RtlUserThreadStart
 
 Stacks for Running Threads:
 
 Call Stack for Thread 6992:
 0x00007FFDAFC7C144 (ntdll) NtWaitForSingleObject
 0x00007FFDADA18BC3 (KERNELBASE) WaitForSingleObjectEx
 ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FFD39931E1E)
 0x00007FFD39931E1E (UnityPlayer) (function-name not available)
 ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FFD3991C87B)
 0x00007FFD3991C87B (UnityPlayer) (function-name not available)
 0x00007FFD39ABFB30 (UnityPlayer) UnityMain
 0x00007FFD39A8869F (UnityPlayer) UnityMain
 0x000002152D59DC03 (UnityEngine.CoreModule) UnityEngine.Texture2D.ReadPixelsImpl_Injected()
 0x000002152D59DB43 (UnityEngine.CoreModule) UnityEngine.Texture2D.ReadPixelsImpl()
 0x000002152D59D94B (UnityEngine.CoreModule) UnityEngine.Texture2D.ReadPixels()
 0x000002152D59D8BB (UnityEngine.CoreModule) UnityEngine.Texture2D.ReadPixels()
 0x000002152D595A93 (Assembly-CSharp) Capture.Update()
 0x000002152D1BDAD0 (mscorlib) System.Object.runtime_invoke_void__this__()
 0x00007FFD4A9EB7B0 (mono-2.0-bdwgc) mono_get_runtime_build_info
 0x00007FFD4A971892 (mono-2.0-bdwgc) mono_perfcounters_init
 0x00007FFD4A97A88F (mono-2.0-bdwgc) mono_runtime_invoke
 0x00007FFD39C81674 (UnityPlayer) UnityMain
 0x00007FFD39C7EEA0 (UnityPlayer) UnityMain
 0x00007FFD39C6A4A9 (UnityPlayer) UnityMain
 0x00007FFD39C6A663 (UnityPlayer) UnityMain
 0x00007FFD39A58620 (UnityPlayer) UnityMain
 0x00007FFD39B88B67 (UnityPlayer) UnityMain
 0x00007FFD39B88C09 (UnityPlayer) UnityMain
 0x00007FFD39B8ABBF (UnityPlayer) UnityMain
 ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FFD39963BD5)
 0x00007FFD39963BD5 (UnityPlayer) (function-name not available)
 ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FFD3996220A)
 0x00007FFD3996220A (UnityPlayer) (function-name not available)
 ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FFD39966A90)
 0x00007FFD39966A90 (UnityPlayer) (function-name not available)
 0x00007FFD3996ACCB (UnityPlayer) UnityMain
 ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF740A211FA)
 0x00007FF740A211FA (TracerRenderer) (function-name not available)
 0x00007FFDAF8E7BD4 (KERNEL32) BaseThreadInitThunk
 0x00007FFDAFC4CED1 (ntdll) RtlUserThreadStart

 
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

200 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

plugin inspector not working for OSX bundle 1 Answer

Unity - How to add native view to Unity main activity? 0 Answers

Using .framework for iOS as Plugin. 0 Answers

Audio Spatializer Plugin SDK: how can plugin get channel count of input audio source? 0 Answers

Is there a contained memory enviornment for a Native DLL's memory allocation between Editor and Game modes? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges