Giter Site home page Giter Site logo

Comments (8)

atharvsharma1998 avatar atharvsharma1998 commented on August 22, 2024 1

yes adding @pragma('vm:entry-point') to callbackDispatcher and the onEvents method solved the issue. Thanks. is it recommended to be added to every event listener?

from flutter-radar.

KennyHuRadar avatar KennyHuRadar commented on August 22, 2024

Can you try adding the vm entry point to the callbackDispatcher instead like such

@pragma('vm:entry-point')
void callbackDispatcher() {
  const MethodChannel _backgroundChannel =
      MethodChannel('flutter_radar_background');
  WidgetsFlutterBinding.ensureInitialized();

  _backgroundChannel.setMethodCallHandler((MethodCall call) async {
    final args = call.arguments;
    final CallbackHandle handle = CallbackHandle.fromRawHandle(args[0]);
    final Function? callback = PluginUtilities.getCallbackFromHandle(handle);
    final Map res = args[1];
    
    callback?.call(res);
  });
}

It may also be helpful to add the following to your proguard-rules.pro while debugging:

// this will force R8 to not keep all Radar related classes
-keep class io.radar.** { *; }
// This will print all the classes that were removed by the obfuscation
-printusage debug-dir/usage.txt
// This will print the classes that "seed" what is kept by the obfuscation
-printseeds debug-dir/seeds.txt

from flutter-radar.

atharvsharma1998 avatar atharvsharma1998 commented on August 22, 2024

Thanks for the fix, but using it didn't work. I'm getting error

E/flutter (26098): [ERROR:flutter/lib/ui/dart_runtime_hooks.cc(38)] Dart Error: Dart_LookupLibrary: library 'package:hot_frontend/screens/MapScreen.dart' not found.

from flutter-radar.

atharvsharma1998 avatar atharvsharma1998 commented on August 22, 2024

I haven't been able to exactly follow the workaround as the file structure/logic have changed so couldn't tell if this solution works or not. Also, is this issue reproducible by radar team as I'm getting it in example radar project too?
flutter/flutter#91841 (comment)
flutter/flutter#91841 (comment)

from flutter-radar.

KennyHuRadar avatar KennyHuRadar commented on August 22, 2024

I am seeing a different error on the example app.

E/flutter (27400): [ERROR:flutter/lib/ui/dart_runtime_hooks.cc(38)] Dart Error: Class '_MyAppState' not found in library ''.
E/flutter (27400): [ERROR:flutter/shell/common/shell.cc(117)] Dart Error: Class '_MyAppState' not found in library ''.

I think the new entry point annotation was able to resolve the issue of the obfuscation but may introduce a new issue. We are looking into it.

from flutter-radar.

KennyHuRadar avatar KennyHuRadar commented on August 22, 2024

I was able to suppress the errors that I was getting on the example app by adding the same annotation to the static methods we want to use as callbacks.

@pragma('vm:entry-point')
static void onEvents(Map res) {
print('📍📍 onEvents: $res');
}
  .....
Radar.onEvents(onEvents);

This is done in addition to adding the annotation to the callbackDispatcher as described in #41 (comment)

from flutter-radar.

KennyHuRadar avatar KennyHuRadar commented on August 22, 2024

Yes, all event listeners are "passed into the native layer". As such, we need to add the annotation for them so that they can be executed when the native code executes the callback.

We will be cutting a release with this fix soon! Hopefully this workaround is sufficient in the meantime.

from flutter-radar.

atharvsharma1998 avatar atharvsharma1998 commented on August 22, 2024

issue patched in v3.9.1

from flutter-radar.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.