Firebase .on()侦听器会导致Cordova iOS应用崩溃 [英] Firebase .on() listener causes Cordova iOS app crash

查看:352
本文介绍了Firebase .on()侦听器会导致Cordova iOS应用崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个空白的,全新的科尔多瓦应用程序(-v 6.3.1),并为iOS构建。该应用程序除了以下内容什么都不做:

  var ref = new Firebase('url-to-firebase-leaf-node-with -4000儿'); 
ref.on(child_added,function(child,prev){
console.log(here);
});

部署到iPhone。应用程序崩溃,Xcode引用以下内容:
$ b $ p code WebThread(7):EXC_BAD_ACCESS(code = 1,address = 0xbbadbeef)里面的 bmalloc :: VMHeap :: grow()



如果我这样做: / p>

var ref = new Firebase('url-to-firebase-leaf-node-with-100-children');

这显然是一个内存问题,但是如何解决呢?从4000个子节点中抽取1.5Mb的数据,我不会想象这应该占用所有可用的内存。请避免不提取所有数据的建议 - 应用程序需要所有的数据,并在Android上正常工作。

解决方案

非常有表现力应用程序耗尽内存。



Firebase SDK使用您的订阅来构建数据库的内存镜像。即使您的 child_added 回调函数对子快照没有任何作用,这个内部树也使用内存来存储节点下的所有数据

>

因此,您应该考虑对订阅使用限制,引入分页,或者如果数据库适合您的域模型,则应该重新构建数据库。


I have made a blank, brand new Cordova app (-v 6.3.1), and built for iOS. The app does nothing except the following:

var ref = new Firebase('url-to-firebase-leaf-node-with-4000-children');
ref.on("child_added", function(child, prev) {
    console.log("here");
});

Deploy to iPhone. The app crashes, and Xcode cites the following:

WebThread (7): EXC_BAD_ACCESS (code=1, address=0xbbadbeef) inside of bmalloc::VMHeap::grow() .

If I do this rather:

var ref = new Firebase('url-to-firebase-leaf-node-with-100-children'); then the app doesn't crash.

This is clearly a memory problem, but how can it be resolved? With 1.5Mb of data being pulled down from 4,000 child nodes, I wouldn't have imagined this should be using up all available memory. Please avoid suggestions of not pulling all the data - the app needs all the data and works fine on Android.

解决方案

The native crash is pretty expressive. The application runs out of memory.

The Firebase SDK builds an in-memory mirror of the database using your subscriptions. Even if your child_added callback does not do anything with the child snapshots, this internal tree uses memory for all the data under the node.

Therefore you should consider using limits on your subscription, introducing pagination, or even restructuring the database if it fits your domain model.

这篇关于Firebase .on()侦听器会导致Cordova iOS应用崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆