amirrajan / rubymotion-applied

RubyMotion documentation provided by the community. Submit a pull request to the docs for a free one year indie subscription.
Apache License 2.0
50 stars 9 forks source link

GoogleAnalytics crashes RM gen_bridge_metadata #106

Open caramdache opened 6 years ago

caramdache commented 6 years ago

I have been using GoogleAnalytics with RM for years without any issue and suddenly it crashed RM immediately after running rake. I downloaded the latest version of GA, but RM still crashes.

It looks like the issue is in gen_bridge_metadata.

     Build ./build/iPhoneSimulator-12.0-Development
     Build vendor/GoogleAnalytics
Ignoring bigdecimal-1.3.5 because its extensions are not built.  Try: gem pristine bigdecimal --version 1.3.5
Ignoring bigdecimal-1.3.4 because its extensions are not built.  Try: gem pristine bigdecimal --version 1.3.4
Ignoring date-1.0.0 because its extensions are not built.  Try: gem pristine date --version 1.0.0
Ignoring dbm-1.0.0 because its extensions are not built.  Try: gem pristine dbm --version 1.0.0
/Library/RubyMotion/lib/BridgeSupport2/System/Library/BridgeSupport/ruby-2.3/bridgesupportparser.bundle: [BUG] Segmentation fault at 0x0000000000c96522
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
-- Control frame information -----------------------------------------------
c:0010 p:-17569455029594 s:0047 e:000046 TOP    [FINISH]
c:0009 p:---- s:0045 e:000044 CFUNC  :require
c:0008 p:0124 s:0041 e:000040 METHOD /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55
c:0007 p:0035 s:0031 e:000030 TOP    /Library/RubyMotion/lib/BridgeSupport2/System/Library/BridgeSupport/ruby-2.3/bridgesupportparser.rb:6 [FINISH]
c:0006 p:---- s:0029 e:000028 CFUNC  :require
c:0005 p:0124 s:0025 e:000024 METHOD /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55
c:0004 p:0215 s:0015 e:000014 TOP    /Library/RubyMotion/lib/BridgeSupport2/usr/bin/gen_bridge_metadata:65 [FINISH]
c:0003 p:---- s:0010 e:000009 CFUNC  :load
c:0002 p:0128 s:0006 E:0013d0 EVAL   /Library/RubyMotion/bin/gen_bridge_metadata:36 [FINISH]
c:0001 p:0000 s:0002 E:0000f0 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
/Library/RubyMotion/bin/gen_bridge_metadata:36:in `<main>'
/Library/RubyMotion/bin/gen_bridge_metadata:36:in `load'
/Library/RubyMotion/lib/BridgeSupport2/usr/bin/gen_bridge_metadata:65:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Library/RubyMotion/lib/BridgeSupport2/System/Library/BridgeSupport/ruby-2.3/bridgesupportparser.rb:6:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'

-- Machine register context ------------------------------------------------
 rax: 0x0000000000000000 rbx: 0x00000000082dee80 rcx: 0x0000000105bea7b0
 rdx: 0x0000000000000000 rdi: 0x00000001068b7d49 rsi: 0x000000001f08000c
 rbp: 0x00007ffeea1a5990 rsp: 0x00007ffeea1a5918  r8: 0x0000000000000000
  r9: 0x0000000000000000 r10: 0x0000000000000000 r11: 0x0000000000000000
 r12: 0x0000000000000003 r13: 0x00007fd5a70be5d0 r14: 0x00007fd5a903f350
 r15: 0x00007ffeea1a59a0 rip: 0x0000000000c96522 rfl: 0x0000000000010246

-- C level backtrace information -------------------------------------------
0   libruby.2.3.0.dylib                 0x00007fff4681a006 rb_print_backtrace + 29
1   libruby.2.3.0.dylib                 0x00007fff4681a1da rb_vm_bugreport + 361
2   libruby.2.3.0.dylib                 0x00007fff46715413 rb_bug_context + 206
3   libruby.2.3.0.dylib                 0x00007fff467b1422 Init_signal + 3270
4   libsystem_platform.dylib            0x00007fff687afb3d _sigtramp + 29
5   ???                                 0x0000000000c96522 0x0 + 13198626
6   bridgesupportparser.bundle          0x0000000105bea7d7 Init_bridgesupportparser + 39
7   libruby.2.3.0.dylib                 0x00007fff466e6551 dln_load + 229
8   libruby.2.3.0.dylib                 0x00007fff4680efc8 rb_vm_call_cfunc + 169
9   libruby.2.3.0.dylib                 0x00007fff4671db33 rb_require_internal + 1496
10  libruby.2.3.0.dylib                 0x00007fff4671d4b5 rb_require_safe + 14
11  libruby.2.3.0.dylib                 0x00007fff468120d8 rb_vm_fstring_table + 4999
12  libruby.2.3.0.dylib                 0x00007fff46803021 rb_vm_get_insns_address_table + 8039
13  libruby.2.3.0.dylib                 0x00007fff4680e77c rb_iseq_eval + 414
14  libruby.2.3.0.dylib                 0x00007fff4671d418 rb_load_protect + 562
15  libruby.2.3.0.dylib                 0x00007fff4671dbf6 rb_require_internal + 1691
16  libruby.2.3.0.dylib                 0x00007fff4671d4b5 rb_require_safe + 14
17  libruby.2.3.0.dylib                 0x00007fff468120d8 rb_vm_fstring_table + 4999
18  libruby.2.3.0.dylib                 0x00007fff46803021 rb_vm_get_insns_address_table + 8039
19  libruby.2.3.0.dylib                 0x00007fff4680e77c rb_iseq_eval + 414
20  libruby.2.3.0.dylib                 0x00007fff4671d418 rb_load_protect + 562
21  libruby.2.3.0.dylib                 0x00007fff4671d174 rb_load + 64
22  libruby.2.3.0.dylib                 0x00007fff4671e141 Init_load + 659
23  libruby.2.3.0.dylib                 0x00007fff468120d8 rb_vm_fstring_table + 4999
24  libruby.2.3.0.dylib                 0x00007fff46803021 rb_vm_get_insns_address_table + 8039
25  libruby.2.3.0.dylib                 0x00007fff4680e77c rb_iseq_eval + 414
26  libruby.2.3.0.dylib                 0x00007fff46719e6a ruby_exec_node + 232
27  libruby.2.3.0.dylib                 0x00007fff46719d5d ruby_run_node + 39
28  ruby                                0x0000000105a591bd main + 98
amirrajan commented 6 years ago

What's the name of the cocoapod and version?

What function are you invoking?

caramdache commented 6 years ago

Hi Amir, I don't use pods in this instance, I downloaded the latest version (3.17) at:

   https://developers.google.com/analytics/devguides/collection/ios/v3/sdk-download

Here are the methods that I use:

      GAI.sharedInstance.trackUncaughtExceptions = false
      GAI.sharedInstance.dispatchInterval = UIDevice.development? ? 5 : 60*2
      #GAI.sharedInstance.logger.setLogLevel(KGAILogLevelVerbose)
      #GAI.sharedInstance.dispatch # manual dispatch
      GAI.sharedInstance.trackerWithTrackingId(GoogleKey)

      tracker = GAI.sharedInstance.defaultTracker
      tracker.set(KGAIScreenName, string)
      params = {
        GAIFields.customDimensionForIndex(index) => userLevel,
        GAIFields.customMetricForIndex(index) => value,
      }
      builder = GAIDictionaryBuilder.createScreenView
      builder = GAIDictionaryBuilder.createEventWithCategory(string, action, label, value)
      tracker.send(builder.setAll(params).build)
amirrajan commented 6 years ago

Is there a possibility that you can put up a sample app that includes the sdk in the ./vendor directory as you are doing?

Aside: double check and make sure that any cached files are removed from ~/Library/RubyMotion/build.

amirrajan commented 6 years ago

And if you can share the output of rake config that would be helpful too.

amirrajan commented 6 years ago

Also, it seems like Google is deprecating "everything" (eg Crashlytics) and putting it all into their Firebase SDK. Just something to look out for.

caramdache commented 6 years ago

Here is a sample project that demonstrate the issue. ga.zip

Inside the projet, there is a file called rake.config. It is the output of rake config.

Thanks for the tip, I'll have a look at Firebase (again).

caramdache commented 6 years ago

BTW, using pod 'Firebase/Core will also create an expection in gen-bridge-metadata.

amirrajan commented 6 years ago

I'll take a look this weekend and get you an update 👍

amirrajan commented 6 years ago

@caramdache are you on High Sierra or Mojave?

caramdache commented 6 years ago

Mojave of course.

amirrajan commented 6 years ago

Mind joining this Slack discussion (if you're not already a part of it)? https://motioneers.slack.com/archives/C055RDLS0/p1537915072000100

amirrajan commented 6 years ago

Related and may fix your issue. Mind trying it? https://trac.macports.org/ticket/54939

Run the following command:

cd /Applications/Xcode.app/Contents/Developer/Toolchains
sudo ln -s XcodeDefault.xctoolchain OSX10.14.xctoolchain
amirrajan commented 6 years ago

Here is what we are doing in the Slack channel right now (you may want to try it and see if it works for you):

amirrajan commented 6 years ago

The following steps should resolve your issue. After I've tested it, it'll be part of RubyMotion vNext (which I'll release ASAP): https://gist.github.com/Atastor/2e85ee4fab03aaab391594b6fa769931

caramdache commented 6 years ago

Thanks Amir, I'm on slack now. Recompiling BridgeSupport is a huge endeavour. I will wait for RM's next release to be available.

amirrajan commented 6 years ago

try this out: https://www.dropbox.com/s/ixryj9ne9o7c83h/bridge_support_2.tgz?dl=0

just back up what's under /Library/RubyMotion/lib/BridgeSupport2 and replace the contents with what's under the tarbal

amirrajan commented 6 years ago

after copying the following files over, run:

sudo mkdir -p /usr/local/lib/
sudo ln -s "$(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib" /usr/local/lib/
caramdache commented 6 years ago

It's much better now, thanks !

This constant is no longer defined though and causes a crash:

KGAIScreenName

Here's how it's defined in GoogleAnalytics:

GAIFields.h: extern NSString *const kGAIScreenName;
amirrajan commented 6 years ago

Take a look at the generated bridgesupport file and see if its in there.

The bridgesupport files should be under ~/Library/RubyMotion/build

amirrajan commented 6 years ago

I've released a beta: https://s3.us-east-2.amazonaws.com/amirrajan-public/RubyMotion+5.15.pkg

Mind giving that a shot?

caramdache commented 6 years ago

Hmm... looks bad. A simple app that I was working on these past 2 weeks now raises this error when running rake. I did a rake clean:all first of course. This happening at link phase.

Undefined symbols for architecture x86_64:
  "_DATETIME_COMPONENTS_DO_NOT_USE", referenced from:
      ___concrete__DATETIME_COMPONENTS_DO_NOT_USE in EventKit_stubs.o
     (maybe you meant: ___concrete__DATETIME_COMPONENTS_DO_NOT_USE)
  "_DATE_COMPONENTS_DO_NOT_USE", referenced from:
      ___concrete__DATE_COMPONENTS_DO_NOT_USE in EventKit_stubs.o
     (maybe you meant: ___concrete__DATE_COMPONENTS_DO_NOT_USE)
  "_EK_LOSE_FRACTIONAL_SECONDS_DO_NOT_USE", referenced from:
      ___concrete__EK_LOSE_FRACTIONAL_SECONDS_DO_NOT_USE in EventKit_stubs.o
     (maybe you meant: ___concrete__EK_LOSE_FRACTIONAL_SECONDS_DO_NOT_USE)
  "_NSNotFound", referenced from:
      _MREP_24D7704EB71146F78E6F6C542012B873 in NSString_extensions.rb.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
rake aborted!
Command failed with status (1): [/Applications/Xcode.app/Contents/Developer...]
/Library/RubyMotion/lib/motion/project/builder.rb:375:in `build'
/Library/RubyMotion/lib/motion/project/app.rb:78:in `build'
/Users/jj/.rubymotion/rubymotion-templates/motion/project/template/ios.rb:70:in `block (2 levels) in <top (required)>'
/Users/jj/.rubymotion/rubymotion-templates/motion/project/template/ios.rb:183:in `block in <top (required)>'
/usr/local/lib/ruby/gems/2.5.0/gems/rake-12.3.1/exe/rake:27:in `<top (required)>'
Tasks: TOP => build:simulator
caramdache commented 6 years ago

HELP Amir! How do I go back to a version that compiles? Is there a package I can download? I am stuck now.

caramdache commented 6 years ago

Work around until there is a fix:

amirrajan commented 6 years ago

beta 2: https://s3.us-east-2.amazonaws.com/amirrajan-public/RubyMotion-5.15-beta-2.pkg