Insert more then x documents blocks UI
See original GitHub issueHi, I have strange problem. This is my sample code:
import React, { Component } from 'react';
import {
View,
Text,
TouchableNativeFeedback
} from 'react-native';
import Realm from 'realm';
Realm.clearTestState();
const ProductSchema = {
name: 'Product',
properties: {
variantId: 'string',
productId: 'string',
productNamePL: 'string',
productNameEN: { type: 'string', optional: true },
variantNamePL: 'string',
variantNameEN: { type: 'string', optional: true },
type: { type: 'int', optional: true },
unit: { type: 'int', optional: true },
tax: { type: 'int', optional: true },
pricePLN: { type: 'double', default: 0 },
priceEUR: { type: 'double', default: 0 },
priceUSD: { type: 'double', default: 0 },
priceRUB: { type: 'double', default: 0 },
priceCHF: { type: 'double', default: 0 },
priceGBP: { type: 'double', default: 0 }
}
};
const config = {
schema: [ProductSchema],
};
let realm = new Realm(config);
export default class App extends Component {
save() {
console.log('start')
try {
realm.write(() => {
for (const i = 0; i < 1175; i++) {
const product = {
variantId: 'variant' + i,
productId: 'product' + 1,
productNamePL: 'Variant name',
productNameEN: 'Variant name',
variantNamePL: 'Variant name',
variantNameEN: 'Variant name',
type: 1,
unit: 500,
tax: 8,
pricePLN: 10,
priceEUR: 8,
priceUSD: 5,
priceRUB: 9,
priceCHF: 3,
priceGBP: 12
};
realm.create('Product', product);
}
});
console.log('done');
} catch (e) {
console.log(e);
}
}
render() {
return (
<View style={{
backgroundColor: 'white',
flex: 1,
alignItems: 'center',
justifyContent: 'center',
}}>
<TouchableNativeFeedback
onPress={this.save}
background={TouchableNativeFeedback.SelectableBackground()}>
<View style={{
width: 150,
height: 100,
backgroundColor: 'red',
alignItems: 'center',
justifyContent: 'center'
}}>
<Text>Tap</Text>
</View>
</TouchableNativeFeedback>
</View>
);
}
};
The problem is, when I insert more then 1175 documents (e.g. call twice save() or change i < 1176) the react-native UI is blocked. Checked on different devices, always number of documents which block UI is the same. This is not a fault of documents count, but documents size. When change some strings length - can insert more documents, etc. UI blocked only when I exceed number of documents while using app. When i close app and run again, I can insert next 1175. Realm has some limitation per session or it’s a bug? Realm 0.15.4 (the same problem on 0.14.3) React Native 0.38.0
Issue Analytics
- State:
- Created 7 years ago
- Comments:19 (3 by maintainers)
Top Results From Across the Web
About Modular Blocks field - Contentstack
Modular Blocks is a field that allows content managers to dynamically create and modify components of a page or app on the go....
Read more >Build FixedDocument without blocking UI - wpf - Stack Overflow
I'm generating a document for DocumentViewer. It's slow, so I want to free the UI thread. Using async/await I get an exception saying,...
Read more >BlockUIContainer Class (System.Windows.Documents)
A block-level flow content element which enables UIElement elements (i.e. a Button) to be embedded (hosted) in flow content.
Read more >Layout and the containing block - CSS: Cascading Style Sheets
The size and position of an element are often impacted by its containing block. Most often, the containing block is the content area...
Read more >Review UI Overview
Reviewing changes is an important task and the Gerrit Web UI provides many ... The change metadata block contains detailed information about the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I got the same problem. In my case, i tried to insert/update about 4000+ documents, the app get hang for a while then become normal. Any idea?
Below is the code which I use to insert records