Skip to content
This repository has been archived by the owner on Nov 21, 2023. It is now read-only.

Filter subscriptions on iOS crashes simulator #14

Open
bricestacey opened this issue Jan 25, 2023 · 7 comments
Open

Filter subscriptions on iOS crashes simulator #14

bricestacey opened this issue Jan 25, 2023 · 7 comments

Comments

@bricestacey
Copy link
Contributor

bricestacey commented Jan 25, 2023

I am using commit 0c2ab3d as the subsequent commits have broken the iOS simulator for me.

When I try to use a filter subscription, using the example app, the entire simulator crashes.

I followed the instructions in App.tsx and updated where I create a new node

if (!nodeStarted) {
  let config = new Config();
  config.relay = false;
  config.filter = true;

  await newNode(config);
  await start();
}

I also commented out the relay subscription:

// await relaySubscribe();

And then I uncommented the filter subscription part

try {
  const filterSubs = new FilterSubscription(); 
  filterSubs.contentFilters.push(
    new ContentFilter(`/foo/0/default/${name}`)
  );
  await filterSubscribe(
    filterSubs,
    '16Uiu2HAkvWiyFsgRhuJEb9JfjYxEkoHLgnUQmr1N5mKWnYjxYRVm'
  );
} catch (e) {
  console.log(e);
}

Once filterSubscribe is called, the simulator crashes (the actual Simulator app). I am on an M1 mac if that matters.

@fryorcraken fryorcraken added this to Waku Jan 25, 2023
@richard-ramos
Copy link
Member

Thanks for reporting!
Do you see any stacktrace in the logs (maybe on adb) that could help debug this issue?

@bricestacey
Copy link
Contributor Author

Here is the crash report https://gist.github.com/bricestacey/20d74b22b6654a79e9f77bf7ff8f7b95

I'm not too familiar with iOS development so not sure how to get anything better.

@bricestacey
Copy link
Contributor Author

I was able to run it on Android and got much better error reporting

01-31 23:18:00.304  5738  5794 I ReactNativeJS: {"pubsubTopic":"/waku/2/default-waku/proto","contentFilters":[{"contentTopic":"dingo"}]}
01-31 23:18:00.308  5738     0 E Go      : panic: runtime error: invalid memory address or nil pointer dereference
01-31 23:18:00.308  5738     0 E Go      : [signal SIGSEGV: segmentation violation code=0x1 addr=0x38 pc=0x775d647f7c]
01-31 23:18:00.308  5738     0 E Go      : 
01-31 23:18:00.308  5738     0 E Go      : goroutine 17 [running, locked to thread]:
01-31 23:18:00.309  5738     0 E Go      : github.com/waku-org/go-waku/waku/v2/protocol/filter.(*WakuFilter).requestSubscription(0x0, {0x775dd76eb0, 0x4000122000}, {{0x40017c0a00, 0x1a}, {0x40002d3ad0, 0x1, 0x1}}, {0x400041a2b8, 0x1, ...})
01-31 23:18:00.309  5738     0 E Go      : 	/home/jenkins/workspace/go-waku_prs_android_PR-403/src/github.com/waku-org/go-waku/waku/v2/protocol/filter/waku_filter.go:235 +0x6c
01-31 23:18:00.309  5738     0 E Go      : github.com/waku-org/go-waku/waku/v2/protocol/filter.(*WakuFilter).Subscribe(0x0, {0x775dd76eb0?, 0x4000122000?}, {{0x40017c0a00, 0x1a}, {0x40002d3ad0, 0x1, 0x1}}, {0x400041a2b8?, 0x775d0e79a4?, ...})
01-31 23:18:00.309  5738     0 E Go      : 	/home/jenkins/workspace/go-waku_prs_android_PR-403/src/github.com/waku-org/go-waku/waku/v2/protocol/filter/waku_filter.go:346 +0x78
01-31 23:18:00.309  5738     0 E Go      : github.com/waku-org/go-waku/mobile.FilterSubscribe({0x4000363200?, 0x0?}, {0x0, 0x0}, 0x0)
01-31 23:18:00.309  5738     0 E Go      : 	/home/jenkins/workspace/go-waku_prs_android_PR-403/src/github.com/waku-org/go-waku/mobile/api_filter.go:66 +0x2b8
01-31 23:18:00.309  5738     0 E Go      : main.proxygowaku__FilterSubscribe({0xb4000078dd90c610, 0x58, {0x0, 0x0, 0x0, 0x0}}, {0x0, 0x0, {0x0, 0x0, ...}}, ...)
01-31 23:18:00.309  5738     0 E Go      : 	/tmp/gomobile-work-587595317/src/gobind/go_gowakumain.go:152 +0x6c
01-31 23:18:00.309  5738  5899 E GoLog   : panic: runtime error: invalid memory address or nil pointer dereference
01-31 23:18:00.310  5738  5795 F libc    : Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 5795 (mqt_native_modu), pid 5738 (com.example)

Note that the logging shows the go-waku lib is built from your PR #403. So using that commit, it looks like a null dereference here https://github.com/waku-org/go-waku/blob/3ef88b3b9a9df871468a66bc68f39cf5609f0b38/waku/v2/protocol/filter/waku_filter.go#L235

@richard-ramos
Copy link
Member

This one from android is very useful. Thank you! I'll attempt to fix it today

@bricestacey
Copy link
Contributor Author

As I was saying, I was using an old commit -- so I bumped to the latest and I got it working!

The build instructions were confusing, but I eventually figured it out. I'll try and document some of those for you later today.

@bricestacey
Copy link
Contributor Author

Alright --

First issue was if you run yarn bootstrap you wind up with this error:

$ yarn --cwd example pods
error Command "pods" not found.

This can be solved by adding a pods script to package.json

  "pods": "npx pod-install"

At this point, if you try to run the example with npm run ios you get:

> 1 | import Gowaku
    |        ^ no such module 'Gowaku'

This can be solved by running the download-gowaku.sh script. It uses wget which is not installed by default on mac devices, so I had to install that using brew. Running it again, it succeeds but npm run ios still fails with the same error. Turns out, you needs to cd to example/node_modules/@waku/react-native and run it there.

After downloading gowaku in the node modules folder, it's still complaining about no such module. To solve this we re run the pod install

yarn example pods

At this point you can run yarn example ios or yarn example android and everything works! 🎉

@richard-ramos
Copy link
Member

Thank you! I'll update the README this week with these instructions

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants