View Issue Details

IDProjectCategoryView StatusLast Update
0029804CommunityOCCT:Visualizationpublic2018-05-25 11:14
ReporterVico Liang Assigned Tobugmaster  
PrioritynormalSeverityminor 
Status closedResolutionno change required 
PlatformAndroidOSAndroid 
Product Version7.3.0 
Summary0029804: V3d_View::Remove() trigger error in sample AndroidQt
DescriptionIn normal application design, V3d_View need to be removed when its host window or widget get destroyed, so i try to remove view in AndroidQt destructor. It will trigger the error as below:
E libEGL : eglMakeCurrent:800 error 3002 (EGL_BAD_ACCESS)
TagsNo tags attached.
Test case number

Activities

kgv

2018-05-23 07:51

developer   ~0076115

What exactly are you trying to do? Please provide an updated sample.

Vico Liang

2018-05-23 10:01

developer   ~0076123

Steps to produce the issue:

1. Add a function in AndroidQt class
AndroidQt::removeView()
{
    myView->Remove();
}

2. Add a button on the QML file main.qml
Button {
    id: control
    onClicked: viewer.removeView()
}

After removeView, the error message will occur in QtCreator output window:
E libEGL : eglMakeCurrent:800 error 3002 (EGL_BAD_ACCESS)

Vico Liang

2018-05-23 10:03

developer   ~0076124

I mean V3d_View::Remove() should not call any opengl API, such as eglMakeCurrent.

kgv

2018-05-23 10:05

developer   ~0076125

Why you need to do that in that way?
QtQuick application is multi-threaded by default - it has two dedicated threads for GUI logic and for OpenGL rendering. Check Qt documentation on this topic.

myView->Remove() is expected to be called from OpenGL rendering thread - this is why it emits the error message.

Vico Liang

2018-05-23 10:57

developer   ~0076137

I see that there are two threads for QtQuick. It seems not practicable to call myView->Remove() in OpenGL rendering thread, so where and how should we call Remove()?

Vico Liang

2018-05-23 11:01

developer   ~0076139

I want to use multiple views sharing a single viewer (graphic driver) and so when a view finished its task, it need to be removed from Viewer.

kgv

2018-05-23 12:06

developer   ~0076152

Sorry, but questions about creation of multiple Views are out of scope of this sample - it is designed for the simplest case, with single View covering entire window.

If you need help with these questions, you may try a luck on the User forum or contact Support Services.
I have not tried (yet) such scenarios in QtQuick application, but would expect that there might be more issues to be solved at application (and, maybe, at OCCT site) apart from error message on View removal.

Vico Liang

2018-05-23 12:27

developer   ~0076161

Dear kgv, multiple Views are not present at the same time, they are switchable inside QML stackView or SwipView. each view is also covering the entire window. The problem is not multiple views, but the API V3d_view::Remove() method should not trigger error.

kgv

2018-05-23 12:31

developer   ~0076163

I don't get why you need removing the View and not just sticking with single View and manipulating its properties, when needed.

Vico Liang

2018-05-23 15:21

developer   ~0076177

Thank you for you options. But anyway, even if there is an only view, its lifetime should be end up at some point. It's unavoidable to call Remove() function.

kgv

2018-05-23 15:37

developer   ~0076179

Within this sample, removing of View is done at the end of application life, so that releasing of OpenGL and other memory objects would be a good style, but has no actual effect (and can actually take extra time without real need).

Hence, error message can be just ignored in this case.

Vico Liang

2018-05-23 16:23

developer   ~0076184

It will call remove in V3d_View destructor, and also the error will be triggered even if not call V3d_View::Remove() explicitly. See below stack trace:

V3d_View::~V3d_View()
{
  if (!myView->IsRemoved())
  {
    myView->Remove();
  }
}

void OpenGl_View::Remove()
{
  if (IsRemoved())
  {
    return;
  }

  myDriver->RemoveView (this);
  myWindow.Nullify();

  Graphic3d_CView::Remove();
}

void OpenGl_GraphicDriver::RemoveView (const Handle(Graphic3d_CView)& theView)
{
  Handle(OpenGl_Context) aCtx = GetSharedContext();
  Handle(OpenGl_View) aView = Handle(OpenGl_View)::DownCast (theView);
  if (aView.IsNull())
  {
    return;
  }

  if (!myMapOfView.Remove (aView))
  {
    return;
  }

  Handle(OpenGl_Window) aWindow = aView->GlWindow();
  if (!aWindow.IsNull()
    && aWindow->GetGlContext()->MakeCurrent())
  {
    aCtx = aWindow->GetGlContext();
  }
  else
  {
    // try to hijack another context if any
    const Handle(OpenGl_Context)& anOtherCtx = GetSharedContext();
    if (!anOtherCtx.IsNull()
      && anOtherCtx != aWindow->GetGlContext())
    {
      aCtx = anOtherCtx;
      aCtx->MakeCurrent();
    }
  }

  aView->ReleaseGlResources (aCtx);
  if (myMapOfView.IsEmpty())
  {
    // The last view removed but some objects still present.
    // Release GL resources now without object destruction.
    for (NCollection_DataMap<Standard_Integer, OpenGl_Structure*>::Iterator aStructIt (myMapOfStructure);
         aStructIt.More (); aStructIt.Next())
    {
      OpenGl_Structure* aStruct = aStructIt.ChangeValue();
      aStruct->ReleaseGlResources (aCtx);
    }

    if (!myMapOfStructure.IsEmpty())
    {
      aView->StructureManager()->SetDeviceLost();
    }
  }
}

kgv

2018-05-23 16:25

developer   ~0076186

> It will call remove in V3d_View destructor,
> and also the error will be triggered
> even if not call V3d_View::Remove() explicitly. See below stack trace:
>> Hence, error message can be just ignored in this case.

Vico Liang

2018-05-23 16:29

developer   ~0076188

Agreed, the error message might can be ignored.

kgv

2018-05-24 18:35

developer   ~0076294

Dear bugmaster,

please close this issue.

Issue History

Date Modified Username Field Change
2018-05-23 03:58 Vico Liang New Issue
2018-05-23 03:58 Vico Liang Assigned To => kgv
2018-05-23 04:00 Vico Liang Product Version => 7.3.0
2018-05-23 04:02 Vico Liang OS => Android
2018-05-23 04:02 Vico Liang Platform => Android
2018-05-23 07:51 kgv Note Added: 0076115
2018-05-23 07:51 kgv Assigned To kgv => Vico Liang
2018-05-23 07:51 kgv Status new => feedback
2018-05-23 10:01 Vico Liang Note Added: 0076123
2018-05-23 10:03 Vico Liang Note Added: 0076124
2018-05-23 10:04 Vico Liang Assigned To Vico Liang => kgv
2018-05-23 10:05 Vico Liang Status feedback => assigned
2018-05-23 10:05 kgv Note Added: 0076125
2018-05-23 10:05 kgv Assigned To kgv => Vico Liang
2018-05-23 10:05 kgv Status assigned => feedback
2018-05-23 10:57 Vico Liang Note Added: 0076137
2018-05-23 11:01 Vico Liang Note Added: 0076139
2018-05-23 11:02 Vico Liang Assigned To Vico Liang => kgv
2018-05-23 11:02 Vico Liang Status feedback => assigned
2018-05-23 12:06 kgv Note Added: 0076152
2018-05-23 12:06 kgv Assigned To kgv => Vico Liang
2018-05-23 12:06 kgv Status assigned => feedback
2018-05-23 12:07 kgv Resolution open => no change required
2018-05-23 12:27 Vico Liang Note Added: 0076161
2018-05-23 12:31 kgv Note Added: 0076163
2018-05-23 12:34 Vico Liang Assigned To Vico Liang => kgv
2018-05-23 12:34 Vico Liang Status feedback => assigned
2018-05-23 15:21 Vico Liang Note Added: 0076177
2018-05-23 15:37 kgv Note Added: 0076179
2018-05-23 16:23 Vico Liang Note Added: 0076184
2018-05-23 16:25 kgv Note Added: 0076186
2018-05-23 16:29 Vico Liang Note Added: 0076188
2018-05-24 18:35 kgv Note Added: 0076294
2018-05-24 18:35 kgv Assigned To kgv => bugmaster
2018-05-24 18:35 kgv Status assigned => feedback
2018-05-25 11:14 bugmaster Status feedback => closed