crazecoder / flutter_bugly

腾讯Bugly flutter应用更新统计及异常上报插件,支持Android、iOS
Other
595 stars 163 forks source link

iOS不上报 #62

Open kaina404 opened 4 years ago

kaina404 commented 4 years ago

现在支持上报iOS的错误么?我是纯flutter项目测试,在iOS真机上测试,没有上报错误。

crazecoder commented 4 years ago

debug模式下吗?debug需要设置debugUpload=true

kaina404 commented 4 years ago

是代码问题么?

void main() async {
 FlutterBugly.postCatchedException((){
    runApp(CustomTheme(
      initialThemeKey: brightness,
      child: MyApp(),
    ));
  }, debugUpload: true);
   FlutterBugly.init(androidAppId: "xxxx",iOSAppId: "xxxx");
}

在debug模式下,直接

FlutterBugly.uploadException( message: "${Platform.isAndroid ? "Android " : "iOS"} Error", detail: "iosError Detail");

是可以上传的,但是,flutter直接跑出的异常,例如我直接弄一个flutter异常:


════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following assertion was thrown building Container:
A RenderSliverPadding expected a child of type RenderSliver but received a child of type RenderLimitedBox.

RenderObjects expect specific types of children because they coordinate with their children during layout and paint. For example, a RenderSliver cannot be the child of a RenderBox because a RenderSliver does not understand the RenderBox layout protocol.
The RenderSliverPadding that expected a RenderSliver child was created by: SliverPadding ← SliverSafeArea ← Viewport ← IgnorePointer-[GlobalKey#87dbe] ← Semantics ← _PointerListener ← Listener ← _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#fc293] ← _PointerListener ← Listener ← _ScrollableScope ← ⋯
The RenderLimitedBox that did not match the expected child type was created by: LimitedBox ← Container ← MediaQuery ← SliverPadding ← SliverSafeArea ← Viewport ← IgnorePointer-[GlobalKey#87dbe] ← Semantics ← _PointerListener ← Listener ← _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#fc293] ← ⋯
User-created ancestor of the error-causing widget was: 
  SliverSafeArea file:///xxx.dart:652:9
When the exception was thrown, this was the stack: 
#0      RenderObjectWithChildMixin.debugValidateChild.<anonymous closure> (package:flutter/src/rendering/object.dart:2840:9)
#1      RenderObjectWithChildMixin.debugValidateChild (package:flutter/src/rendering/object.dart:2867:6)
#2      SingleChildRenderObjectElement.insertChildRenderObject (package:flutter/src/widgets/framework.dart:5141:25)
#3      RenderObjectElement.attachRenderObject (package:flutter/src/widgets/framework.dart:4986:35)
#4      RenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4752:5)
...
════════════════════════════════════════════════════════════════════════════════════════════════════

没看到上报。在下面断点时也没走到: image

不知道哪里的问题。。。。

crazecoder commented 4 years ago

android会上报吗?

kaina404 commented 4 years ago

android会上报吗?

Android主动调用上报异常会的,但是flutter抛出的异常不会。

crazecoder commented 4 years ago

你catch了?

kaina404 commented 4 years ago

你catch了?

你看下我发的截图,在那里debug了,但是没走到。。。。

crazecoder commented 4 years ago

catch不会走,在某一步throw "test"试试,看会不会上报

YanCorey commented 4 years ago

我也是遇到同样的问题,界面上已经报错了,没有catch,但是postCatchedException异常捕获那里没有捕获到异常信息

YanCorey commented 4 years ago

找到原因了,初始化的界面得是StatefulWidget才行,如果是StatelessWidget就捕获不到异常了,大神能告知这是为啥吗?

crazecoder commented 4 years ago

@YanCorey 我自己项目就是stateless,不太清楚你遇到的问题,但是应该不是stateless导致的

crazecoder commented 4 years ago

@kaina404

════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following assertion was thrown building Container:
A RenderSliverPadding expected a child of type RenderSliver but received a child of type RenderLimitedBox.

RenderObjects expect specific types of children because they coordinate with their children during layout and paint. For example, a RenderSliver cannot be the child of a RenderBox because a RenderSliver does not understand the RenderBox layout protocol.
The RenderSliverPadding that expected a RenderSliver child was created by: SliverPadding ← SliverSafeArea ← Viewport ← IgnorePointer-[GlobalKey#87dbe] ← Semantics ← _PointerListener ← Listener ← _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#fc293] ← _PointerListener ← Listener ← _ScrollableScope ← ⋯
The RenderLimitedBox that did not match the expected child type was created by: LimitedBox ← Container ← MediaQuery ← SliverPadding ← SliverSafeArea ← Viewport ← IgnorePointer-[GlobalKey#87dbe] ← Semantics ← _PointerListener ← Listener ← _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#fc293] ← ⋯
User-created ancestor of the error-causing widget was: 
  SliverSafeArea file:///xxx.dart:652:9
When the exception was thrown, this was the stack: 
#0      RenderObjectWithChildMixin.debugValidateChild.<anonymous closure> (package:flutter/src/rendering/object.dart:2840:9)
#1      RenderObjectWithChildMixin.debugValidateChild (package:flutter/src/rendering/object.dart:2867:6)
#2      SingleChildRenderObjectElement.insertChildRenderObject (package:flutter/src/widgets/framework.dart:5141:25)
#3      RenderObjectElement.attachRenderObject (package:flutter/src/widgets/framework.dart:4986:35)
#4      RenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4752:5)
...
════════════════════════════════════════════════════════════════════════════════════════════════════

~注意到问题了,Exception caught by widgets library,被widgets里catch了~

FlutterError.onError = (details) {}

这个方法会监听flutter framework的报错,包括上面的widgets catch

https://github.com/flutter/flutter/issues/44407