当前位置: 首页 > 面试题库 >

Google Firebase导致java.lang.StackOverflowError

慕容铭
2023-03-14
问题内容

我正在尝试使用Google
Firebase实时数据库。我的用户可以创建要在数据库中作为独立表以及在用户类中作为列表进行的事件。这是我用来将事件写入数据库以及发生异常的位置:

mDatabase.child("users").child(ResourceManager.getUser().getId()).child("events").setValue(event);

mDatabase.child("events").setValue(ResourceManager.getAllEvents());

问题是,当我尝试保存创建的事件时,我开始收到消息,表明垃圾回收运行了几次,然后在该异常结束时打印了100次相同的异常,然后应用程序重新启动。

06-30 18:38:19.555 15005-15005/tvfriends.kolio.com.tvproba E/AndroidRuntime:     at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                             at com.google.android.gms.internal.zzaix.zzav(Unknown Source)
                                                                             at com.google.firebase.database.DatabaseReference.zza(Unknown Source)
                                                                             at com.google.firebase.database.DatabaseReference.setValue(Unknown Source)
                                                                             at tvfriends.kolio.com.tvproba.HostActivity.onClick(HostActivity.java:109)
                                                                             at android.view.View.performClick(View.java:5609)
                                                                             at android.view.View$PerformClick.run(View.java:22238)
                                                                             at android.os.Handler.handleCallback(Handler.java:751)
                                                                             at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                             at android.os.Looper.loop(Looper.java:154)
                                                                             at android.app.ActivityThread.main(ActivityThread.java:6044)
                                                                             at java.lang.reflect.Method.invoke(Native Method)
                                                                             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
                                                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

同样在顶部异常的末尾,我又得到了一个

06-30 18:38:21.478 15005-15005/tvfriends.kolio.com.tvproba D/Error: ERR: TOTAL BYTES WRITTEN: 13034964
06-30 18:38:21.484 15005-15005/tvfriends.kolio.com.tvproba E/JavaBinder: !!! FAILED BINDER TRANSACTION !!!  (parcel size = 13035048)
06-30 18:38:21.485 15005-15005/tvfriends.kolio.com.tvproba E/AndroidRuntime: Error reporting crash
                                                                            android.os.TransactionTooLargeException: data parcel size 13035048 bytes
                                                                             at android.os.BinderProxy.transactNative(Native Method)
                                                                             at android.os.BinderProxy.transact(Binder.java:615)
                                                                             at android.app.ActivityManagerProxy.handleApplicationCrash(ActivityManagerNative.java:5100)
                                                                             at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:97)
                                                                             at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
                                                                             at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1063)

在我的Event类中,我尝试存储以下变量:

private TVEvent tvEvent;
private User host;
private long date;
private String location;
private TVSet tvSet;
private List<User> attending;
private int eventStatus;

TVEvent,TVSet和User中每个都有一个位图以及大多数原始数据。那么这是什么问题呢?任何帮助深表感谢。

编辑

这是stackoverflow错误:

 D/Error: ERR: stack=java.lang.StackOverflowError: stack size 8MB
                                                                    at java.lang.reflect.Method.invoke(Native Method)
                                                                    at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaw(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix.zzaD(Unknown Source)
                                                                    at com.google.android.gms.internal.zzaix$zza.zzaE(Unknown Source)
                                                                    at com.google.android.gms.internal.zz
06-30 18:38:21.447 15005-15012/tvfriends.kolio.com.tvproba W/art: Suspending all threads took: 64.352ms
06-30 18:38:21.478 15005-15005/tvfriends.kolio.com.tvproba D/Error: ERR: TOTAL BYTES WRITTEN: 13034964

问题答案:

您尝试存储的数据大小setValue()可能太大,很可能是由位图数据引起的。

可以使用Parcels在Android组件之间传递数据,但数据量限制为1MB。该TransactionTooLargeException发生,因为一些组件,你的任何一个或火力地堡组件处理您的请求之一,尝试发送包含超过1MB的数据包裹。您看到的垃圾收集重复运行的报告是您处理正在请求大量内存的另一个指示。

这个新问题是否意味着您不再需要其他问题的帮助?如果是这样,请取消赏金。

TVSet.compressImage()针对您的其他问题发布的代码中的方法表明您正在对全尺寸图像进行Base64编码并存储结果。这是您希望存储在数据库中的数据的一部分。这不是FirebaseDatabase的最佳用法。考虑使用FirebaseStorage来存储仅具有文件名或其他标识密钥存储在数据库中的图像。



 类似资料:
  • 问题内容: 我注意到执行和启动任务有时会抛出EXC_BAD_ACCESS。给出错误的实际调用方法似乎有所不同,但始终来自。在大多数情况下,调用方法来自。我在下面附加了两个崩溃日志,其中包含不同的调用方。我还附加了的实现。 不幸的是,我无法可靠地重现该错误,因此没有共享的示例脚本。创建和启动对象最终将产生错误。较大的文件似乎更经常发生。我在这里实施错了吗?有没有一种好的方法可以从此堆栈跟踪进行调试?

  • 问题内容: Javascript上找到的脚本是:如何获取在中断标签之后/之前的文本节点,并用ddb标签包装它们? 在通过WebDriver加载的每个页面上运行时, 测试运行3分钟后出现以下错误: 基本上,其目的是捕获xpath语法无法选择的文本节点。Javascript在带有break的break标签之前和之后包装文本节点。然后,WebDriver可以使用xpath语法获取文本。 事情似乎运行顺利

  • 我有点进退两难。我无法调试我的C OpenGL程序,因为激活调试消息会导致segfault。 我注册了一个调试回调函数: 我在以下代码中启动调试上下文: 如果我只是注释掉

  • 问题内容: 调用反射值的.FieldByName方法时出现以下错误,确切的错误是:- 和代码是:- 我了解的并不多,但这就是我所能获得的所有信息。 这是Go Playground上代码的链接:http : //play.golang.org/p/E038cPOoGp 问题答案: 您已经是一个指向结构的指针。尝试打印出您的代码。 没有理由使用的地址,然后调用that ,它会取消对刚创建的指针的引用。

  • 我有两个类与多对多关系相连: book.java category.java 添加@column注释后,的问题得到了解决。但是,映射集合的问题就出现了。下面是我收到的堆栈轨迹: 编辑2 当我将@jointable中的从id更改为book_id时,我收到了如下所示的DataIntegrityViolationException:

  • 当我尝试使用@autowired时,它给了我例外 当我在没有@autowired注释的情况下尝试它时,这段代码很好,但当我添加@autowired时,它给了我 像这样的很少,我认为spring-dispatcher-servlet.xml中有问题,我搜索了很多,仍然没有找到问题。我有任何jar文件需要添加到项目中....??