-
-
Notifications
You must be signed in to change notification settings - Fork 194
Hotfix for Release 2.0.4 #438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,6 @@ import androidx.activity.ComponentActivity | |
import androidx.lifecycle.DefaultLifecycleObserver | ||
import androidx.lifecycle.Lifecycle | ||
import androidx.lifecycle.LifecycleOwner | ||
import androidx.lifecycle.coroutineScope | ||
import com.google.android.filament.Engine | ||
import com.google.android.filament.IndirectLight | ||
import com.google.android.filament.MaterialInstance | ||
|
@@ -45,9 +44,7 @@ import io.github.sceneview.model.Model | |
import io.github.sceneview.model.ModelInstance | ||
import io.github.sceneview.node.LightNode | ||
import io.github.sceneview.node.Node | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.launch | ||
import java.util.concurrent.Executors | ||
|
||
/** | ||
* A SurfaceView that integrates with ARCore and renders a scene | ||
|
@@ -565,8 +562,6 @@ open class ARSceneView @JvmOverloads constructor( | |
|
||
override fun destroy() { | ||
if (!isDestroyed) { | ||
destroyARCore() | ||
|
||
defaultCameraNode?.destroy() | ||
defaultCameraStream?.destroy() | ||
|
||
|
@@ -577,14 +572,6 @@ open class ARSceneView @JvmOverloads constructor( | |
super.destroy() | ||
} | ||
|
||
fun destroyARCore() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is no reasons to place public function cuz it's internal behavior |
||
val scope = lifecycle?.coroutineScope ?: CoroutineScope(Dispatchers.IO) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I wrote in issue - Coroutines is not fit tool to execute background operation a specialty on Destroy callback |
||
scope.launch(Dispatchers.IO) { | ||
// destroy should be called off the main thread since it hangs for many seconds | ||
arCore.destroy() | ||
} | ||
} | ||
|
||
class DefaultARCameraNode(engine: Engine) : ARCameraNode(engine) { | ||
init { | ||
// Set the exposure on the camera, this exposure follows the sunny f/16 rule | ||
|
@@ -608,7 +595,10 @@ open class ARSceneView @JvmOverloads constructor( | |
} | ||
|
||
override fun onDestroy(owner: LifecycleOwner) { | ||
destroyARCore() | ||
Executors.newSingleThreadExecutor().execute { | ||
// destroy should be called off the main thread since it hangs for many seconds | ||
arCore.destroy() | ||
} | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You use LifeCycleObserver as the main place to call ArCore lifecycle functions
And you don't need to call it here again
I didn't find any side cases