App stops responding to touches after popping a view controller containing an ARKit scene view
I have a navigation controller containing a root view controller which contains a single UIButton. Tapping the button pushes another view controller on to the stack. This second view controller contains an ARKit sceneView (ARSCNView). Inside the scene, I add a node using an SCNPlane, and set the plane's material's diffuse contents to use a view backed by a view controller like so:
import UIKit
import SceneKit
import ARKit
class SceneViewController: UIViewController {
@IBOutlet weak var sceneView: ARSCNView!
override func viewDidLoad() {
super.viewDidLoad()
setupScene()
}
func setupScene() {
sceneView.scene = SCNScene()
let configuration = ARWorldTrackingConfiguration()
sceneView.session.run(configuration, options: [.resetTracking, .removeExistingAnchors])
// add a small plane at the origin...
let plane = SCNPlane(width: 0.1, height: 0.1)
// create a view controller, and add use its view as the plane's material contents...
let vc = UIViewController()
vc.view.backgroundColor = UIColor.red
plane.firstMaterial?.diffuse.contents = vc.view
let node = SCNNode(geometry: plane)
sceneView.scene.rootNode.addChildNode(node)
}
}
When I pop this view controller (using either the back button, or the pan gesture), the root view controller stops responding to touch events.
Rotating the device to landscape, and then back to portrait does seem to free up whatever is causing this behaviour
I've tried overriding touchesBegan on the root view controller, but it doesn't get triggered.
I've tried forcing the window to become first responder.
I've ensured that the SceneViewController is being destroyed, and that the sceneView's session is not still running after the view controller has been destroyed.
This problem doesn't occur when using a UIView, or a UIImage generated from the content view controller's view, but this would mean the it can't be interacted with.
Here's a link to a sample project. It needs to be run on an ARKit capable device: https://github.com/duncanlowrie/vc-node-test
ios swift scenekit arkit
add a comment |
I have a navigation controller containing a root view controller which contains a single UIButton. Tapping the button pushes another view controller on to the stack. This second view controller contains an ARKit sceneView (ARSCNView). Inside the scene, I add a node using an SCNPlane, and set the plane's material's diffuse contents to use a view backed by a view controller like so:
import UIKit
import SceneKit
import ARKit
class SceneViewController: UIViewController {
@IBOutlet weak var sceneView: ARSCNView!
override func viewDidLoad() {
super.viewDidLoad()
setupScene()
}
func setupScene() {
sceneView.scene = SCNScene()
let configuration = ARWorldTrackingConfiguration()
sceneView.session.run(configuration, options: [.resetTracking, .removeExistingAnchors])
// add a small plane at the origin...
let plane = SCNPlane(width: 0.1, height: 0.1)
// create a view controller, and add use its view as the plane's material contents...
let vc = UIViewController()
vc.view.backgroundColor = UIColor.red
plane.firstMaterial?.diffuse.contents = vc.view
let node = SCNNode(geometry: plane)
sceneView.scene.rootNode.addChildNode(node)
}
}
When I pop this view controller (using either the back button, or the pan gesture), the root view controller stops responding to touch events.
Rotating the device to landscape, and then back to portrait does seem to free up whatever is causing this behaviour
I've tried overriding touchesBegan on the root view controller, but it doesn't get triggered.
I've tried forcing the window to become first responder.
I've ensured that the SceneViewController is being destroyed, and that the sceneView's session is not still running after the view controller has been destroyed.
This problem doesn't occur when using a UIView, or a UIImage generated from the content view controller's view, but this would mean the it can't be interacted with.
Here's a link to a sample project. It needs to be run on an ARKit capable device: https://github.com/duncanlowrie/vc-node-test
ios swift scenekit arkit
add a comment |
I have a navigation controller containing a root view controller which contains a single UIButton. Tapping the button pushes another view controller on to the stack. This second view controller contains an ARKit sceneView (ARSCNView). Inside the scene, I add a node using an SCNPlane, and set the plane's material's diffuse contents to use a view backed by a view controller like so:
import UIKit
import SceneKit
import ARKit
class SceneViewController: UIViewController {
@IBOutlet weak var sceneView: ARSCNView!
override func viewDidLoad() {
super.viewDidLoad()
setupScene()
}
func setupScene() {
sceneView.scene = SCNScene()
let configuration = ARWorldTrackingConfiguration()
sceneView.session.run(configuration, options: [.resetTracking, .removeExistingAnchors])
// add a small plane at the origin...
let plane = SCNPlane(width: 0.1, height: 0.1)
// create a view controller, and add use its view as the plane's material contents...
let vc = UIViewController()
vc.view.backgroundColor = UIColor.red
plane.firstMaterial?.diffuse.contents = vc.view
let node = SCNNode(geometry: plane)
sceneView.scene.rootNode.addChildNode(node)
}
}
When I pop this view controller (using either the back button, or the pan gesture), the root view controller stops responding to touch events.
Rotating the device to landscape, and then back to portrait does seem to free up whatever is causing this behaviour
I've tried overriding touchesBegan on the root view controller, but it doesn't get triggered.
I've tried forcing the window to become first responder.
I've ensured that the SceneViewController is being destroyed, and that the sceneView's session is not still running after the view controller has been destroyed.
This problem doesn't occur when using a UIView, or a UIImage generated from the content view controller's view, but this would mean the it can't be interacted with.
Here's a link to a sample project. It needs to be run on an ARKit capable device: https://github.com/duncanlowrie/vc-node-test
ios swift scenekit arkit
I have a navigation controller containing a root view controller which contains a single UIButton. Tapping the button pushes another view controller on to the stack. This second view controller contains an ARKit sceneView (ARSCNView). Inside the scene, I add a node using an SCNPlane, and set the plane's material's diffuse contents to use a view backed by a view controller like so:
import UIKit
import SceneKit
import ARKit
class SceneViewController: UIViewController {
@IBOutlet weak var sceneView: ARSCNView!
override func viewDidLoad() {
super.viewDidLoad()
setupScene()
}
func setupScene() {
sceneView.scene = SCNScene()
let configuration = ARWorldTrackingConfiguration()
sceneView.session.run(configuration, options: [.resetTracking, .removeExistingAnchors])
// add a small plane at the origin...
let plane = SCNPlane(width: 0.1, height: 0.1)
// create a view controller, and add use its view as the plane's material contents...
let vc = UIViewController()
vc.view.backgroundColor = UIColor.red
plane.firstMaterial?.diffuse.contents = vc.view
let node = SCNNode(geometry: plane)
sceneView.scene.rootNode.addChildNode(node)
}
}
When I pop this view controller (using either the back button, or the pan gesture), the root view controller stops responding to touch events.
Rotating the device to landscape, and then back to portrait does seem to free up whatever is causing this behaviour
I've tried overriding touchesBegan on the root view controller, but it doesn't get triggered.
I've tried forcing the window to become first responder.
I've ensured that the SceneViewController is being destroyed, and that the sceneView's session is not still running after the view controller has been destroyed.
This problem doesn't occur when using a UIView, or a UIImage generated from the content view controller's view, but this would mean the it can't be interacted with.
Here's a link to a sample project. It needs to be run on an ARKit capable device: https://github.com/duncanlowrie/vc-node-test
ios swift scenekit arkit
ios swift scenekit arkit
asked Nov 26 '18 at 11:57
Duncan LowrieDuncan Lowrie
1163
1163
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I am encountering the same issue. It turns out that if you assign an SKScene to the plane.firstMaterial?.diffuse.contents, this behaviour goes away, but you need the UIView (as do I) for obvious reasons.
Also, I think only about two thirds of the screen becomes unresponsive. I tried it on an iPhone 7 and iPhone XS and if you try to interact with whatever is on the bottom third of your screen, it should work. Ugly bug.
Tried as well to reinstantiate the AppDelegate's window's rootViewController with a fresh entrypoint from the Storyboard: no joy.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53480635%2fapp-stops-responding-to-touches-after-popping-a-view-controller-containing-an-ar%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I am encountering the same issue. It turns out that if you assign an SKScene to the plane.firstMaterial?.diffuse.contents, this behaviour goes away, but you need the UIView (as do I) for obvious reasons.
Also, I think only about two thirds of the screen becomes unresponsive. I tried it on an iPhone 7 and iPhone XS and if you try to interact with whatever is on the bottom third of your screen, it should work. Ugly bug.
Tried as well to reinstantiate the AppDelegate's window's rootViewController with a fresh entrypoint from the Storyboard: no joy.
add a comment |
I am encountering the same issue. It turns out that if you assign an SKScene to the plane.firstMaterial?.diffuse.contents, this behaviour goes away, but you need the UIView (as do I) for obvious reasons.
Also, I think only about two thirds of the screen becomes unresponsive. I tried it on an iPhone 7 and iPhone XS and if you try to interact with whatever is on the bottom third of your screen, it should work. Ugly bug.
Tried as well to reinstantiate the AppDelegate's window's rootViewController with a fresh entrypoint from the Storyboard: no joy.
add a comment |
I am encountering the same issue. It turns out that if you assign an SKScene to the plane.firstMaterial?.diffuse.contents, this behaviour goes away, but you need the UIView (as do I) for obvious reasons.
Also, I think only about two thirds of the screen becomes unresponsive. I tried it on an iPhone 7 and iPhone XS and if you try to interact with whatever is on the bottom third of your screen, it should work. Ugly bug.
Tried as well to reinstantiate the AppDelegate's window's rootViewController with a fresh entrypoint from the Storyboard: no joy.
I am encountering the same issue. It turns out that if you assign an SKScene to the plane.firstMaterial?.diffuse.contents, this behaviour goes away, but you need the UIView (as do I) for obvious reasons.
Also, I think only about two thirds of the screen becomes unresponsive. I tried it on an iPhone 7 and iPhone XS and if you try to interact with whatever is on the bottom third of your screen, it should work. Ugly bug.
Tried as well to reinstantiate the AppDelegate's window's rootViewController with a fresh entrypoint from the Storyboard: no joy.
answered Dec 8 '18 at 22:08
Teodor Iuliu RaduTeodor Iuliu Radu
113
113
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53480635%2fapp-stops-responding-to-touches-after-popping-a-view-controller-containing-an-ar%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown