# Debugging touch events on filter

**URL:** <https://forum.deepar.ai/t/debugging-touch-events-on-filter/650>\
**Category:** Help & Questions\
**Tags:** effect-help, studio-tutorials\
**Created:** [May 1, 2024, 5:52pm UTC](https://forum.deepar.ai/t/debugging-touch-events-on-filter/650 "2024-05-01T17:52:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![andyfries](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.deepar.ai/andyfries/32/654_2.png) [@andyfries](https://forum.deepar.ai/u/andyfries)\
**Post date:** [May 1, 2024, 5:52pm UTC](https://forum.deepar.ai/t/debugging-touch-events-on-filter/650/1 "2024-05-01T17:52:25Z")

</div>

I’m following the realtime face painting tutorial from [Realtime AR Face Painting | DeepAR Help Center](https://help.deepar.ai/en/articles/6641626-realtime-ar-face-painting) in my React Native/Expo iOS app using [react-native-deepar](https://github.com/ridvanaltun/react-native-deepar/tree/master) and I’m having issues with touch events.

My setup works fine for many other filters, but for some reason I’m not able to get anything to draw onscreen as a result of the touch. The effect works fine in DeepAR Studio live preview, and I’ve confirmed that touch events are being passed through the React Native wrapper to the underlying DeepAR SDK, but then nothing happens.

I recognize the React Native library I’m using is community supported and detailed help may not be available, so I’m interested more in tips about how I might debug this issue rather than an actual solution. If touch events are being sent to the SDK and the effect is being loaded correctly, what else can I check? Are there debug options within the effect script that I could use to verify behavior somehow? I see I can output debug logs in DeepAR Studio, but I’m not sure that’s intended to work when deployed in my app as well.

Thanks in advance,  
Andy

---

<div class="post-metadata">

**Author:** ![jelena](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.deepar.ai/jelena/32/14_2.png) [@jelena](https://forum.deepar.ai/u/jelena)\
**Post date:** [May 2, 2024, 6:44pm UTC](https://forum.deepar.ai/t/debugging-touch-events-on-filter/650/2 "2024-05-02T18:44:48Z")

</div>

You can try using scripting to trigger an event on touch [DeepAR Scripting API: Home](https://docs.deepar.ai/scripting/api-reference), but my best guess is that the touches aren’t being sent to the SDK in a way it can read them

[https://docs.deepar.ai/deepar-sdk/deep-ar-sdk-for-ios/api-reference/documentation/deepar/touchtype](https://docs.deepar.ai/deepar-sdk/deep-ar-sdk-for-ios/api-reference/documentation/deepar/touchtype)

---

<div class="post-metadata">

**Author:** ![andyfries](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.deepar.ai/andyfries/32/654_2.png) [@andyfries](https://forum.deepar.ai/u/andyfries)\
**Post date:** [May 2, 2024, 7:09pm UTC](https://forum.deepar.ai/t/debugging-touch-events-on-filter/650/3 "2024-05-02T19:09:26Z")

</div>

Thanks for the ideas. Can you elaborate on “touches aren’t being sent to the SDK in a way it can read them”? How would I debug that? The code for sending touches looks fine to me at a glance but I’m not an expert in what the SDK expects

> <https://github.com/ridvanaltun/react-native-deepar/blob/869a6b57581e46b31e6db59b3e2f8443806207e1/ios/RNTDeepAR.m#L284-L292>

---

<div class="post-metadata">

**Author:** ![andyfries](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.deepar.ai/andyfries/32/654_2.png) [@andyfries](https://forum.deepar.ai/u/andyfries)\
**Post date:** [May 6, 2024, 11:47pm UTC](https://forum.deepar.ai/t/debugging-touch-events-on-filter/650/4 "2024-05-06T23:47:47Z")

</div>

Any other thoughts you can offer on this? Looking at the DeepAR tutorial repo for the face paint demo the code looks identical to the react-native-deepar library I’m using (see previous link):

```auto
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    if(event.type == UIEventTypeTouches) {
        UITouch * touch = [touches allObjects][0];
        CGPoint point = [self getPoint:touch];
        TouchInfo info = {point.x, point.y, START};
        [self.deepar touchOccurred:info];
    } else {
        [super touchesBegan:touches withEvent:event];
    }
}

    // Called every time a change in the previously started touch is detected
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    if(event.type == UIEventTypeTouches) {
        UITouch * touch = [touches allObjects][0];
        CGPoint point = [self getPoint:touch];
        TouchInfo info = {point.x, point.y, MOVE};
        [self.deepar touchOccurred:info];
    } else {
        [super touchesMoved:touches withEvent:event];
    }
}

    // Called every time a previously started touch is ended
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    if(event.type == UIEventTypeTouches) {
        UITouch * touch = [touches allObjects][0];
        CGPoint point = [self getPoint:touch];
        TouchInfo info = {point.x, point.y, END};
        [self.deepar touchOccurred:info];
    } else {
        [super touchesEnded:touches withEvent:event];
    }
}

```

---

<div class="post-metadata">

**Author:** ![jelena](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.deepar.ai/jelena/32/14_2.png) [@jelena](https://forum.deepar.ai/u/jelena)\
**Post date:** [May 7, 2024, 11:33am UTC](https://forum.deepar.ai/t/debugging-touch-events-on-filter/650/5 "2024-05-07T11:33:39Z")

</div>

Then I’m not sure, Have you tested if the touches are read correctly with a regular view instead of deepar?

---

<div class="post-metadata">

**Author:** ![andyfries](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.deepar.ai/andyfries/32/654_2.png) [@andyfries](https://forum.deepar.ai/u/andyfries)\
**Post date:** [May 7, 2024, 4:01pm UTC](https://forum.deepar.ai/t/debugging-touch-events-on-filter/650/6 "2024-05-07T16:01:21Z")

</div>

Yep, touches seem to be coming through into the view just fine. I added logging in the react-native-deepar lib around the `touchOccurred` DeepAR SDK call and I do see it’s logging touches with plausibly correct coordinates:

```auto
Touch started: 0.537744, 0.408210, 0
Touch moved: 0.524173, 0.409730, 1
Touch moved: 0.496183, 0.641201, 1
Touch moved: 0.481764, 0.646902, 1
Touch ended: 0.477523, 0.649183, 2

```

Is there any way I can get visibility into what’s happening in DeepAR between this `touchOccurred` call and the `onTouchOccurred` function in my effect script? As far as I can tell, DeepAR is being called with the touch using code that follows the previously linked example, but `onTouchOccurred` isn’t firing.

Full logging code for reference (same pattern applies to `MOVE` and `END`):

```auto
  TouchInfo info = {point.x, point.y, START};
  [self.deepar touchOccurred:info];
  NSLog(@"Touch started: %f, %f, %d", info.x, info.y, info.type);

```

---

<div class="post-metadata">

**Author:** ![jelena](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.deepar.ai/jelena/32/14_2.png) [@jelena](https://forum.deepar.ai/u/jelena)\
**Post date:** [May 7, 2024, 5:36pm UTC](https://forum.deepar.ai/t/debugging-touch-events-on-filter/650/7 "2024-05-07T17:36:11Z")

</div>

> <https://github.com/DeepARSDK/quickstart-ios-swift/commit/865cf6ab9645ed7be7f55123853d1d6007339edf>

This is a different code, for touch support in the swift example, the only differences seem to be:

TouchType.START instead of START  
and converting the point to a location in the arview

I don’t think there’s any more logs that can help you

override func touchesBegan(\_ touches: Set, with event: UIEvent?) {  
super.touchesBegan(touches, with: event)  
let touch = touches.first  
let point = touch?.location(in: self.arView)  
let info = TouchInfo(x: point!.x, y: point!.y, type: TouchType.START);  
self.deepAR.touchOccurred(info)
