OpenCVLoader.initDebug() causes SIGSEGV in libart.so between onPause and onResume in debug sessions (simple repro included) #22515
Labels
bug
needs investigation
Collect and attach more details (build flags, stacktraces, input dumps, etc)
platform: android
System information (version)
Detailed description
Calling OpenCVLoader.initDebug() once at the beginning of an application succeeds, but a SIGSEGV will subsequently be raised in libart.so everytime a screen rotation occurs. The SIGSEGV will be raised in between onPause and onResume calls for the fragment.
Steps to reproduce
Open Android Studio 2021.2.1 Patch 2
File > New > New Project... > Phone and Tablet > select 'Basic Activity'. Make sure the language is set to Java.
Download OpenCV 4.6.0 (latest release) from sourceforget.net and unzip the 'sdk' directory next to the settings.gradle file (also next to the 'app' folder of the application) as a folder named 'opencv' (not 'sdk')
File > New > Import Module... > source directory : the 'opencv' directory mentionned above
Give a name to the opencv module, for instance 'opencv', and finish the import procedure. We now have two projects in the IDE, :app and :opencv
Open settings.gradle and reverse the order of these two lines (for some reason, they are in the wrong order when the project is imported):
get rid of the kotlin extension declaration, as the project is written in Java
Build the project and launch a debug session on a Sony Xperia Z5 Compact (E5823) device with Android 7.1.1 Nougat. The application is launched successfully
The first fragment shows up, now rotate the screen, everything is fine.
Exit the application
Override FirstFragment's onCreate method by adding this code:
Following this edit, the IDE complains OpenCVLoader is not a recognized class - follow the suggestions to import the '........._main' module and then do 'Import class'. Now the class is recognized and everything compiles fine.
Launch a new debug session
'success' will be true, above, as can be seen with the debugger if need be
Now rotate the device's screen
A SIGSEGV occurs after onPause() has been called., and the debugger is entered
Carrying execution with the Continue button works fine (surprisingly ?)
onResume() is called and execution resumes normally.
Any subsequent screen rotation will result in a SIGSEGV.
This is very annoying when debugging on the device, which I always prefer.
At the beginning, I thought it was a problem with my code, so I posted a message on stackoverflow:
SIGSEGV libart.so exception only occuring on one computer when debugging, not on the other
Because I managed to build a simple repro, I am posting this issue here.
Surprisingly, there is one computer on which I don't experience the problem, but it is an older Android Studio version (2021.2.1 with no patch).
Issue submission checklist
forum.opencv.org, Stack Overflow, etc and have not found any solution
The text was updated successfully, but these errors were encountered: