[英]Firebase .on() listener causes Cordova iOS app crash
I have made a blank, brand new Cordova app (-v 6.3.1), and built for iOS. 我制作了一个空白的全新Cordova应用程序(-v 6.3.1),并为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. 部署到iPhone。 The app crashes, and Xcode cites the following:
应用程序崩溃,Xcode引用以下内容:
WebThread (7): EXC_BAD_ACCESS (code=1, address=0xbbadbeef)
inside of bmalloc::VMHeap::grow()
. WebThread (7): EXC_BAD_ACCESS (code=1, address=0xbbadbeef)
bmalloc::VMHeap::grow()
内部的WebThread (7): EXC_BAD_ACCESS (code=1, address=0xbbadbeef)
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.
从4,000个子节点中提取了1.5Mb的数据,我想不到这应该会耗尽所有可用内存。 Please avoid suggestions of not pulling all the data - the app needs all the data and works fine on Android.
请避免提出不要提取所有数据的建议-该应用程序需要所有数据,并且可以在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. Firebase SDK使用您的订阅构建数据库的内存镜像。 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. 即使您的
child_added
回调对子快照不执行任何操作,此内部树child_added
将内存用于节点下的所有数据 。
Therefore you should consider using limits on your subscription, introducing pagination, or even restructuring the database if it fits your domain model. 因此,如果适合您的域模型,则应考虑对订阅使用限制,引入分页甚至重组数据库。
在添加child_added
侦听器之前,请确保已缓存了所有数据(通过上述分页技术或其他方式)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.