Search Unity

problem on rendertexture handling on Android

Discussion in 'General Graphics' started by kyewong, Sep 18, 2015.

  1. kyewong

    kyewong

    Joined:
    Sep 11, 2014
    Posts:
    22
    hi guys,
    I'm trying to pass the target texture of the camera to an .so file for further handling on Android platform.
    Inside the .so file, I do the following steps:
    1) use eglgetcurrentsurface to get the current Unity surface
    2) use eglcreatepbuffersurface to create a new surface, and use eglmakecurrent to pass the newly created surface to unity
    3) use eglmakecurrent to pass the original Unity surface to another thread in .so file and handle the input texture (the target texture of the Unity camera)

    However, when running the program, the phone screen keeps on flicking between the unity splash screen and a black screen, and nothing in the unity scene was rendered on the screen.
    The log captured in the logcat is as follows (the same error keeps on looping):

    09-17 11:01:41.530 547 604 I Unity :
    09-17 11:01:41.530 2999 4324 E BufferQueueProducer: [SurfaceView] connect(P): already connected (cur=1 req=1)
    09-17 11:01:41.530 547 604 E libEGL : eglCreateWindowSurface: native_window_api_connect (win=0xf4cad808) failed (0xffffffea) (already connected to another API?)
    09-17 11:01:41.530 547 604 E libEGL : eglCreateWindowSurface:427 error 3003 (EGL_BAD_ALLOC)
    09-17 11:01:41.530 547 604 E Unity : [EGL] Failed to create surface
    09-17 11:01:41.530 547 604 E Unity :
    09-17 11:01:41.530 547 604 E Unity : (Filename: Line: 224)
    09-17 11:01:41.530 547 604 E Unity :
    09-17 11:01:41.530 547 604 E Unity : [EGL] Error:: EGL_BAD_ALLOC: EGL failed to allocate resources for the requested operation.
    09-17 11:01:41.530 547 604 E Unity :
    09-17 11:01:41.530 547 604 E Unity : (Filename: ./PlatformDependent/AndroidPlayer/Source/ContextGLES.cpp Line: 224)
    09-17 11:01:41.530 547 604 E Unity :
    09-17 11:01:41.530 547 604 I Unity : Skipped frame because GfxDevice is in invalid state (device lost)

    Could you please give me some suggestions on solving this problem please? Is it due to the workflow or the detailed implementation?
    BTW, I'm using Unity 4.6 pro and the same problem occurs on various android platform(Android 4.4, 5.0, 5,1...)