I'm trying to add the Opus library to my project using native plugins. I have it fully working on Android, Windows, and Mac. It's almost working on iOS, except for one function which is causing problems.
This is the C declaration of the function:
`int opus_encoder_ctl(OpusEncoder *st, int request, ...)`
I use this function to get and set the bitrate. It uses varargs, but there's only two variations I use, one where the third argument is an int (for setting the value) and one where it's an int pointer (for getting the value).
This is how I have the functions declared in c sharp:
[DllImport(LIBRARY_NAME, CallingConvention = CallingConvention.Cdecl)]
public static extern int opus_encoder_ctl(IntPtr st, Ctl request, int value);
[DllImport(LIBRARY_NAME, CallingConvention = CallingConvention.Cdecl)]
public static extern int opus_encoder_ctl(IntPtr st, Ctl request, out Int32 value);
I have both variations defined as separate functions. I read that this was the recommended way to call vararg functions from c-sharp, and it works on Android, Windows, Mac, and the iOS emulator. But on iOS devices it has issues. With the "out" argument function (which should correspond to the pointer variation in c), the resulting value is always zero. And with the int argument variation the function behaves strangely, as if I had passed in a much higher bitrate.
It seems like varargs are the issue here, but maybe it's the out argument? Any ideas what could be causing this?
↧
Native plugin problems with varargs on iOS (Opus)
↧
Native Plugin works in editor but not in build
I'm building a virtual synthesizer in Unity by creating sounds using a c++ DLL. The DLL is being run at a custom thread declared in C# inside of Unity. My problem is that the DLL runs perfectly inside the Editor. No crashes or anything. However, when I try to build and run the standalone windows application it just terminates when reaching> waveOutWrite(m_hwDevice, &m_pWaveHeaders[m_nBlockCurrent], sizeof(WAVEHDR));
at the end of the code.
----------
This is the full header file inside the DLL where the crash occurs:
#pragma once
#pragma comment(lib, "winmm.lib")
#include
#include
#include
#include
#include
#include
#include
#include
#define T short
using namespace std;
class SoundEngine
{
public:
SoundEngine() {}
SoundEngine(wstring sOutputDevice, unsigned int nSampleRate = 44100, unsigned int nChannels = 1, unsigned int nBlocks = 8, unsigned int nBlockSamples = 512)
{
Create(sOutputDevice, nSampleRate, nChannels, nBlocks, nBlockSamples);
}
~SoundEngine()
{
Destroy();
}
bool Create(wstring sOutputDevice, unsigned int nSampleRate = 44100, unsigned int nChannels = 1, unsigned int nBlocks = 8, unsigned int nBlockSamples = 512)
{
m_bReady = false;
m_nSampleRate = nSampleRate;
m_nChannels = nChannels;
m_nBlockCount = nBlocks;
m_nBlockSamples = nBlockSamples;
m_nBlockFree = m_nBlockCount;
m_nBlockCurrent = 0;
m_pBlockMemory = nullptr;
m_pWaveHeaders = nullptr;
// Validate device
vector devices = Enumerate();
auto d = std::find(devices.begin(), devices.end(), sOutputDevice);
if (d != devices.end())
{
// Device is available
int nDeviceID = distance(devices.begin(), d);
WAVEFORMATEX waveFormat;
waveFormat.wFormatTag = WAVE_FORMAT_PCM;
waveFormat.nSamplesPerSec = m_nSampleRate;
waveFormat.wBitsPerSample = sizeof(T) * 8;
waveFormat.nChannels = m_nChannels;
waveFormat.nBlockAlign = (waveFormat.wBitsPerSample / 8) * waveFormat.nChannels;
waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec * waveFormat.nBlockAlign;
waveFormat.cbSize = 0;
// Open Device if valid
if (waveOutOpen(&m_hwDevice, nDeviceID, &waveFormat, (DWORD_PTR)waveOutProcWrap, (DWORD_PTR)this, CALLBACK_FUNCTION) != S_OK)
return Destroy();
}
// Allocate Wave|Block Memory
m_pBlockMemory = new T[m_nBlockCount * m_nBlockSamples];
if (m_pBlockMemory == nullptr)
return Destroy();
ZeroMemory(m_pBlockMemory, sizeof(T) * m_nBlockCount * m_nBlockSamples);
m_pWaveHeaders = new WAVEHDR[m_nBlockCount];
if (m_pWaveHeaders == nullptr)
return Destroy();
ZeroMemory(m_pWaveHeaders, sizeof(WAVEHDR) * m_nBlockCount);
// Link headers to block memory
for (unsigned int n = 0; n < m_nBlockCount; n++)
{
m_pWaveHeaders[n].dwBufferLength = m_nBlockSamples * sizeof(T);
m_pWaveHeaders[n].lpData = (LPSTR)(m_pBlockMemory + (n * m_nBlockSamples));
}
m_bReady = true;
m_thread = thread(&SoundEngine::MainThread, this);
// Start the ball rolling
unique_lock lm(m_muxBlockNotZero);
m_cvBlockNotZero.notify_one();
return true;
}
bool Destroy()
{
return false;
}
void Stop()
{
m_bReady = false;
m_thread.join();
}
// Override to process current sample
virtual double UserProcess(int nChannel, double dTime)
{
return 0.0;
}
double GetTime()
{
return m_dGlobalTime;
}
public:
static vector Enumerate()
{
int nDeviceCount = waveOutGetNumDevs();
vector sDevices;
WAVEOUTCAPS woc;
for (int n = 0; n < nDeviceCount; n++)
if (waveOutGetDevCaps(n, &woc, sizeof(WAVEOUTCAPS)) == S_OK)
sDevices.push_back(woc.szPname);
return sDevices;
}
double clip(double dSample, double dMax)
{
if (dSample >= 0.0)
return fmin(dSample, dMax);
else
return fmax(dSample, -dMax);
}
private:
unsigned int m_nSampleRate;
unsigned int m_nChannels;
unsigned int m_nBlockCount;
unsigned int m_nBlockSamples;
unsigned int m_nBlockCurrent;
T* m_pBlockMemory;
WAVEHDR *m_pWaveHeaders;
HWAVEOUT m_hwDevice;
thread m_thread;
atomic m_bReady;
atomic m_nBlockFree;
condition_variable m_cvBlockNotZero;
mutex m_muxBlockNotZero;
atomic m_dGlobalTime;
// Handler for soundcard request for more data
void waveOutProc(HWAVEOUT hWaveOut, UINT uMsg, DWORD dwParam1, DWORD dwParam2)
{
if (uMsg != WOM_DONE) return;
m_nBlockFree++;
unique_lock lm(m_muxBlockNotZero);
m_cvBlockNotZero.notify_one();
}
// Static wrapper for sound card handler
static void CALLBACK waveOutProcWrap(HWAVEOUT hWaveOut, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2)
{
((SoundEngine*)dwInstance)->waveOutProc(hWaveOut, uMsg, dwParam1, dwParam2);
}
// Main thread. This loop responds to requests from the soundcard to fill 'blocks'
// with audio data. If no requests are available it goes dormant until the sound
// card is ready for more data. The block is fille by the "user" in some manner
// and then issued to the soundcard.
void MainThread()
{
m_dGlobalTime = 0.0;
double dTimeStep = 1.0 / (double)m_nSampleRate;
// Goofy hack to get maximum integer for a type at run-time
T nMaxSample = (T)pow(2, (sizeof(T) * 8) - 1) - 1;
double dMaxSample = (double)nMaxSample;
T nPreviousSample = 0;
while (m_bReady)
{
// Wait for block to become available
if (m_nBlockFree == 0)
{
unique_lock lm(m_muxBlockNotZero);
while (m_nBlockFree == 0) // sometimes, Windows signals incorrectly
m_cvBlockNotZero.wait(lm);
}
// Block is here, so use it
m_nBlockFree--;
// Prepare block for processing
if (m_pWaveHeaders[m_nBlockCurrent].dwFlags & WHDR_PREPARED)
waveOutUnprepareHeader(m_hwDevice, &m_pWaveHeaders[m_nBlockCurrent], sizeof(WAVEHDR));
T nNewSample = 0;
int nCurrentBlock = m_nBlockCurrent * m_nBlockSamples;
for (unsigned int n = 0; n < m_nBlockSamples; n += m_nChannels)
{
// User Process
for (unsigned int c = 0; c < m_nChannels; c++)
{
nNewSample = (T)(clip(MakeNoise(c, m_dGlobalTime), 1.0) * dMaxSample);
m_pBlockMemory[nCurrentBlock + n + c] = nNewSample;
nPreviousSample = nNewSample;
}
m_dGlobalTime = m_dGlobalTime + dTimeStep;
}
// Send block to sound device
waveOutPrepareHeader(m_hwDevice, &m_pWaveHeaders[m_nBlockCurrent], sizeof(WAVEHDR));
waveOutWrite(m_hwDevice, &m_pWaveHeaders[m_nBlockCurrent], sizeof(WAVEHDR)); // THIS MAKES EVERYTHING CRASH!!!
m_nBlockCurrent++;
m_nBlockCurrent %= m_nBlockCount;
}
}
virtual double MakeNoise(int a, double b) = 0;
};
Please tell me if I need to clarify anything.
**Thanks in advance!**
↧
↧
Binding EGLImage to RenderTexture (or setting NativeTexturePtr)
I'm trying to get a Unity Camera to render to an EGLImage with some help from a native plugin. I'm running this on Android with OpenGL ES 3.2, using a native plugin to create ANativeWindowBuffer and an EGLImageKHR from that. Now, I'm trying to figure out how to use glEGLImageTargetTexture2DOES with a RenderTexture.
Texture2D has CreateExternalTexture static method, which is really what I'd like to use, but Camera.targetTexture only accepts a RenderTexture and there does not appear to be a way of creating one out of a native OpenGL texture object.
Creating a RenderTexture in Unity and then calling glEGLImageTargetTexture2DOES on GetNativeTexturePtr() works, but only for a single frame. For some reason, the binding is reset after each frame, so I have to reassociate the texture with my image each time and I'm not really sure what the performance implications of this are. Is there a cleaner way of either creating a RenderTexture out of an existing OpenGL object, or changing Unity's RenderTexture instance so that the changes persist across frames?
↧
DllNotFoundException while using unity native c++ Plugins
Getting DllNotFoundException when trying to build a native c++ plugin for Unity.
----------
include "FirstDll.h"
DLLExport int add(int a, int b){
return a+b;
}
FirstDll::FirstDll(){
}
FirstDll::~FirstDll(){
}
----------
FirstDll.h
define DLLExport __declspec(dllexport)
extern "C"{
DLLExport int add(int a, int b);
}
class FirstDll{
public:
FirstDll();
~FirstDll();
};
----------
I am then generating a so file via this command
----------
g++ -dynamiclib -flat_namespace -fms-extensions FirstDll.cpp -o libmyclass.so
----------
I am then added this .so file in Assets/Plugins/x86_64 folder and in my unity c# code, I am trying to run this piece of code.
----------
[DllImport("myclass")]
static extern int add(int a, int b);
----------
After getting this error, I have tried to moved the so file to different locations and test. I am always getting DllNotFoundException.
↧
How to send a whole custom List-Object from unity to Swift/XCode via native plugin?
So recently I wanted to create PDFs on iOS Devices with Apps written in Unity.
Long story short I used [this Tutorial][1] on how to use Apple's PDFKit to create PDFs in Swift.
Next I learnt about native plugins and how to bridge between Unity and Swift with this [Tutorial][2].
And at a final step I combined the two projects with sending a few different strings from Unity UITextField to Swift and trigger the "CreatePDF" -function. I was happy as hell because of my little working prototype showing that it can be done haha :D
But now I want to send a lot of data to Swift. Like a list of custom Data with strings, ints, floats, images and what not.
Let me give you an example. Lets say I have a CarInventory-List and want to send that to Swift to create a PDF of the Inventory. Each car has an id, a price, a model name and a picture. See below.
Any ideas how I put that into a format so that I can extract it in Swift after sending it?
public class Car
{
public int id;
public float price;
public string model;
public Image picture;
public Car(int newId, float newPrice, string newModel, Image newPicture)
{
id = newId;
price = newPrice;
model = newModel;
picture = newPicture;
}
}
public List CarInventory = new List();
[1]: https://www.raywenderlich.com/4023941-creating-a-pdf-in-swift-with-pdfkit
[2]: https://medium.com/@kevinhuyskens/implementing-swift-in-unity-53e0b668f895
↧
↧
Native plugin: UnityPluginLoad not called when run in editor
* Unity 2019.2.12f1
* Windows 10 64-bit
I am developing a native rendering plugin. When I build a standalone Windows x64 build, `UnityPluginLoad` is called as expected when the DLL loads, but when I run my game in the Unity editor, `UnityPluginLoad` is *not* getting called. The DLL still gets loaded successfully. I can call other native methods it contains. The editor is just not calling UnityPluginLoad.
Here are my DLL meta settings:
![DLL settings][1]
[1]: /storage/temp/153548-2020-03-02-15-25-22.png
Am I missing a setting?
↧
Native plugin: DLL loads, but UnityPluginLoad not called (EDITOR ONLY!)
Hello, I'm developing a native rendering plugin DLL, and it works great in a standalone Windows build. But when running in the editor, the DLL loads, but never initialized by a call to `UnityPluginLoad`. This is a method Unity looks for in native plugins and will call it if found. Why would Unity be able to find and call this method in the standalone player but not in the editor?
**Q: How do you know your DLL is loading in the editor?** I know it is loading and executing in the editor because I can attach a native debugger and hit breakpoints.
**Q: Could the DLL export names be mangled?** No, they're not mangled and I have a .def file. When I dump exports using `dumpbin /exports`, I see that the names of the exported functions are not prefixed with underscores.
**Q: Can I get a visual aid please?** Here's a picture that might help convey the issue (maybe). This is C++ code in my native rendering DLL. When I attach a native debugger, the top breakpoint is only hit when running in a standalone player. It is not hit when running in the editor. The bottom breakpoint is hit in both the standalone player and when running in the editor. ![visual aid][1]
I asked this question a few days ago [here](https://answers.unity.com/questions/1704384/native-plugin-unitypluginload-not-called-when-run.html), but I've lost the ability to reply to that question. There's no UI for it! But there are some replies there and some description of troubleshooting I've already tried.
**Platform** * Unity 2019.2.12f1 * Windows 10 64-bit
Thank you for reading this! [1]: /storage/temp/153758-2020-03-06-12-29-54.png
**Q: How do you know your DLL is loading in the editor?** I know it is loading and executing in the editor because I can attach a native debugger and hit breakpoints.
**Q: Could the DLL export names be mangled?** No, they're not mangled and I have a .def file. When I dump exports using `dumpbin /exports`, I see that the names of the exported functions are not prefixed with underscores.
**Q: Can I get a visual aid please?** Here's a picture that might help convey the issue (maybe). This is C++ code in my native rendering DLL. When I attach a native debugger, the top breakpoint is only hit when running in a standalone player. It is not hit when running in the editor. The bottom breakpoint is hit in both the standalone player and when running in the editor. ![visual aid][1]
I asked this question a few days ago [here](https://answers.unity.com/questions/1704384/native-plugin-unitypluginload-not-called-when-run.html), but I've lost the ability to reply to that question. There's no UI for it! But there are some replies there and some description of troubleshooting I've already tried.
**Platform** * Unity 2019.2.12f1 * Windows 10 64-bit
Thank you for reading this! [1]: /storage/temp/153758-2020-03-06-12-29-54.png
↧
Native Plugin: What has to happen in the RenderEvent?
Hello Community,
am developing a native plugin in C++ that will manipulate Unity textures and meshes.
I've noticed in the [official example][1] that it performs such actions as well as rendering actions in a special C++ function called through `GL.IssuePluginEvent` in the C# script.
-
My question is, does any access to GPU memory have to happen inside that function?
-
Surely the rendering tasks have to happen there, but I noticed that I can successfully call `s_CurrentAPI->BeginModifyTexture` from a C++ function that's called from FixedUpdate().
Is this defined behavior or could that lead to unpredictable crashes and I'm forced to do everything graphics related in the RenderEvent?
Huge thanks in advance :)
[1]: https://github.com/Unity-Technologies/NativeRenderingPlugin
↧
Unity rendering 'freezes' when Native Plugin errors out
Hi all,
I'm using a native plugin called 'uDesktopDuplication', this is used for capturing the desktop as part of the project I work on, this can be found here if you want to look over it:
https://github.com/hecomi/uDesktopDuplication/
----------
The issue is that sometimes this plugin will cause Unity's rendering to freeze when it errors out, I believe it sometimes causes an access violation. Regardless, this causes the Unity build's log to be spammed with the following and for nothing to render anymore:
D3D11: Failed to create RenderTexture (670 x 1000 fmt 9 aa 1), error 0x887a0005
d3d11: failed to create 2D texture id=293 width=512 height=1024 mips=1 dxgifmt=65 [D3D error was 887a0005]
d3d11: failed to create 2D texture shader resource view id=293 [D3D error was 80070057]
----------
I've been in touch with the developer of 'uDesktopDuplication' to try to fix the issue but as it's rare/specific to some people's systems, it's hard to find the true cause of it.
I'm wondering is it at all possible to catch the native plugin erroring out? Or have some other means of reloading it as to not totally break the build once it does. I assumed originally it was a Unity bug so I've been through 2019.1, 2, 3, and I'm now on 2020.1 as there was some bug reports with similar crashes that had been resolved.
----------
Let me know your thoughts on this please. :)
↧
↧
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) .()
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
↧
How to get more info about error in crashing app?
Hello! I am developing a Unity app for Android. Application uses NatCorder plugin and some native Android libraries. Till today it works fine. But since today it's crashing after loading a level in Android build, without any log or informative error message.
In Editor/Player mode on Windows all works perfectly. Logcat shows me `"JNI ERROR (app bug): accessed stale Local 0x21"`, but how to find where in code is the place causing this error?
P.S.: I have no easy way to roll back to my previous version of app (where the android built was good). So it'd be last option i'll try.
↧
NativePlugin c++ Android sample and self build pcl not loading,Native Plugins c++ "dll not found"
Hello unity-community,
i got some trouble with native Plugins.
I compiled the pointCloudLib (PCL) into a static and dynamic lib.
Both of them can't be found when calling them like your documentation descripes. (https://docs.unity3d.com/Manual/NativePlugins.html)
Tryed import with:
[DllImport("libnative.so")]
private static extern float add(float x, float y);
[DllImport("native")]
private static extern float add(float x, float y);
With both i get same result:
System DllNotFoundException: libnative.so / native
at (wrapper managed-to-native) CallNativeCode: add(single,single)
at CallNativeCode._callAdd (Single x, Single y) [0x00000] in :0
at Thesis.Scripts.AppController.Update () [0x00000] in :0
File location of Plugins are \Assets\Plugins\Android
Even your sample AndroidNativePlugin-file doesn't work for me.
(https://docs.unity3d.com/Manual/AndroidNativePlugins.html)
Maybe I'm doing something wrong.
I tryed with followed Unity-versions:
- 2018.3.0f2
- 2018.2.15f
- 2017.4.17f1
Thanks in edvance for helping me
Yours sincerely
Stefan
↧
Unity to Native Code Calls Wrong Function
I am using this flavor of [Unity's Google Sign In Button][1]. When I run the app on Android and try to sign in, an exception is thrown. The adb debugger stacktrace includes **Facebook.Unity.IOS.IOSWrapper:.ctor()** which is clearly wrong. How can I determine what is happening here?
The intended extern definition is as follows:
[DllImport(DllName)]
static extern IntPtr GoogleSignIn_SignIn(HandleRef self);
A single stack trace on Android's adb where the exception is thrown, caught, and printed looks like this:
04-30 20:09:58.142 4373 4474 I Unity : Exception of type 'Google.GoogleSignIn+SignInException' was thrown.
04-30 20:09:58.142 4373 4474 I Unity : Facebook.Unity.IOS.IOSWrapper:.ctor()
04-30 20:09:58.142 4373 4474 I Unity : System.Threading.ContextCallback:Invoke(Object)
04-30 20:09:58.142 4373 4474 I Unity : System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
04-30 20:09:58.142 4373 4474 I Unity : System.Runtime.CompilerServices.MoveNextRunner:Run()
04-30 20:09:58.142 4373 4474 I Unity : System.Action:Invoke()
04-30 20:09:58.142 4373 4474 I Unity : System.Threading.ContextCallback:Invoke(Object)
04-30 20:09:58.142 4373 4474 I Unity : System.Threading.Tasks.AwaitTaskContinuation:RunCallback(ContextCallback, Object, Task&)
04-30 20:09:58.142 4373 4474 I Unity : System.Threading.Tasks.Task:FinishContinuations()
04-30 20:09:58.142 4373 4474 I Unity : System.Threading.Tasks.Task:Finish(Boolean)
04-30 20:09:58.142 4373 4474 I Unity : System.Threading.Tasks.Task`1:TrySetException(Object)
04-30 20:09:58.142 4373 4474 I Unity : System.Threading.Tasks.TaskCompletionSource`1:TrySetException(Exception)
04-30 20:09:58.142 4373 4474 I Unity : System.Threading.Tasks.TaskCompletionSource`1:SetException(Exception)
04-30 20:09:58.142 4373 4474 I Unity : Google.d__8:MoveNext()
04-30 20:09:58.142 4373 4474 I Unity : UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
04-30 20:09:58.142 4373 4474 I Unity :
04-30 20:09:58.142 4373 4474 I Unity : (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
04-30 20:09:58.142 4373 4474 I Unity :
[1]: https://github.com/googlesamples/google-signin-unity/pull/126
↧
↧
How to use multiple unity module or unityLibrary into native android application
Hello, Developers. I get one problem while I am following the given tutorial - https://forum.unity.com/threads/integration-unity-as-a-library-in-native-android-app-version-2.751712/
Based on this tutorial I have complete the integration. After doing all required changes my native application Gradle is building successfully. After running the application on real device, Only single Unity Game or Module is loading every time.
Means when I tap for opening first game then first game is opening. But when I am trying for the second game. Then also first game is opening. I am not able to understand the problem. Where I am missing the things.
I have already posted my question here - https://forum.unity.com/threads/integration-unity-as-a-library-in-native-android-app-version-2.751712/page-2#post-5895002 and https://stackoverflow.com/questions/61999970/how-to-embedded-multiple-unity-module-in-native-android
So below is the video link for showing the problem which I am facing. https://drive.google.com/open?id=1F4y-QH50eIkAtlbJnlRQ-ze1_2IS2yiz
After doing all research I am still waiting for the solution. Related to the same question many posts are still I have seen without an answer. So I am expecting some response from the Unity Technology Community.
Means when I tap for opening first game then first game is opening. But when I am trying for the second game. Then also first game is opening. I am not able to understand the problem. Where I am missing the things.
I have already posted my question here - https://forum.unity.com/threads/integration-unity-as-a-library-in-native-android-app-version-2.751712/page-2#post-5895002 and https://stackoverflow.com/questions/61999970/how-to-embedded-multiple-unity-module-in-native-android
So below is the video link for showing the problem which I am facing. https://drive.google.com/open?id=1F4y-QH50eIkAtlbJnlRQ-ze1_2IS2yiz
After doing all research I am still waiting for the solution. Related to the same question many posts are still I have seen without an answer. So I am expecting some response from the Unity Technology Community.
↧
Native Gallery "Error returned from daemon: Error Domain=com.apple.accounts Code=7 "(null)""
The error in the title occurs every time, when I test my unity mobile application on Xcode.
if there's anyone who is familiar with this error, would you give me some advice??
**Unity version:** 2019.2.9f
**Xcode version:** 11.5
**Used Asset**: Native Gallery
**My device for test:** iPhone SE
**Websites I referred:**[iOS: selecting image appears but path not complete (no file extension) #93][1]
[UnityNativeGallery][2]
[Native Gallery for Android & iOS (Open Source)][3]
**Code of Native Gallery on C#**
private void PickImage(int maxSize)
{
NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) =>
{
Debug.Log("Image path: " + path);
if (path != null)
{
// Create Texture from selected image
Texture2D texture = NativeGallery.LoadImageAtPath(path, maxSize);
if (texture == null)
{
Debug.Log("Couldn't load texture from " + path);
return;
}
testImg.texture = texture;
imgPath = path;
}
}, "Select a PNG image", "image/png");
Debug.Log("Permission result: " + permission);
}
**Entire log when Native gallery method is carried out.**
020-06-19 13:18:53.909512+0900 Name of app[3461:1994737] [core] "Error returned from daemon: Error Domain=com.apple.accounts Code=7 "(null)""
2020-06-19 13:18:53.933617+0900 Name of app[3461:1994570] Copied source image from UIImagePickerControllerImageURL
Image path: /var/mobile/Containers/Data/Application/3C80F83D-64EE-4A05-A009-29F9F6585DAA/Library/Caches/pickedImg.png
<>c__DisplayClass7_0:b__0(String)
MediaPickCallback:Invoke(String)
NativeGalleryNamespace.NGMediaReceiveCallbackiOS:OnMediaReceived(String)
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
![alt text][4]
In order to check whether native gallery properly works or not, I use this simple layout for my device test.
[1]: https://github.com/yasirkula/UnityNativeGallery/issues/93
[2]: https://github.com/yasirkula/UnityNativeGallery
[3]: https://forum.unity.com/threads/native-gallery-for-android-ios-open-source.519619/page-13
[4]: /storage/temp/162313-screenshot-2020-06-19-at-140357.png
↧
How to create android notification to keep foreground service alive?
Hi community,
I have been trying to implement a foreground service for android using native code. I have no issue with creating the service itself, but I need to create a notification to inform the user, otherwise the system kills the service after 5 seconds.
I tried this code to create the notification:
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(R.drawable.notification_icon)
.setContentTitle(textTitle)
.setContentText(textContent)
.setPriority(NotificationCompat.PRIORITY_DEFAULT);
But it causes the following error. Apparently Unity cannot find the NotificationCompat class.
06-27 11:30:59.643 9748 9777 E Unity : AndroidJavaException: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/app/NotificationCompat$Builder;
06-27 11:30:59.643 9748 9777 E Unity : java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/app/NotificationCompat$Builder;
Does anybody know an example of how to start a foreground service in android from unity? Or a recent example of how to implement notifications? Most examples on the internet are too old and don't work for android version of API 26 (Oreo) or above.
Regards,
David
↧
How to build IOS library using NativeRenderingPlugin
Hi,
I am new to Unity.
Could anyone let us know or provide a reference, how to generate the IOS library using NativeRenderingPlugin. Where we can use the same IOS library in any of unity projects.
Thanks for your help.
↧
↧
Cross platform native plugin - AskForReviewNow unresponsive on TestFlight
Hi guys,
I have implemented a button that user is supposed to tap and the rating window is expected to pop up. The problem is that when I submit the app for appstore review I get rejected because the button is unresponsive. When I install it using TestFlight it is also unresponsive, but when it works when I instal directly on the phone. I get the rating window pop up with submit button greyed out (which is expected/desired) when installed directly from xcode. I am using simple function:
using UnityEngine;
using VoxelBusters.NativePlugins;
public class RateUs : MonoBehaviour
{
public void AskForReviewNow()
{
NPBinding.Utility.RateMyApp.AskForReviewNow();
}
}
I obviously want to pass the app store review. Do you know what can cause button's unresponsiveness when installed using TestFlight?
↧
How to handle actual process exit?
I'm making a game that uses a native plugin for Windows that must have its shutdown function called when the application exits. The plugin uses an independent worker thread to process a queue, and if that thread doesn't get told to stop, the process will not terminate until the user kills it through the task manager or similar.
Currently, I'm calling the shutdown function from Unity's Application.quitting event. This works fine for a standalone player, but it's unsatisfactory in the Unity editor, because Application.quitting is invoked when the editor leaves play mode, not when the editor is closed. So if you try to close the editor while it's in play mode, shutdown function doesn't get called and the editor becomes unresponsive but doesn't terminate.
There has got to be a better way, something that lets me run code when the actual application is actually closing. Searching the web has only pointed me at functionality in System.Windows.Forms, which doesn't seem to be supported in Unity.
↧
Creating external texture from texture2d?
hello everyone. this is a noob question but it has been bothering me a lot.
why this won't work?
// Create a texture
Texture2D tex = new Texture2D(256, 256, TextureFormat.ARGB32, false);
// Call Apply() so it's actually uploaded to the GPU
tex.Apply();
IntPtr ptr = tex.GetNativeTexturePtr();
var externalTexture = Texture2D.CreateExternalTexture(256, 256, TextureFormat.ARGB32, false, false, ptr);
GetComponent().material.mainTexture = externalTexture;
↧