Closed aiya000 closed 3 years ago
@aiya000 There s not enough log to debug anything. Please post a logcat
@farfromrefug logcat is here
Maybe 09-24 13:46:49.164
is important.
Also you can reproduce this problem on below following :+1:
$ vue init nativescript-vue/vue-cli-template test
$ cd test
$ npm install --save-dev vue-property-decorator
$ tns plugin add nativescript-canvas
$ npm install
$ e app/main.ts app/components/App.vue # Follow README 'NativeScript + Vue' and 'draw Method' of this repo
$ adb logcat
I can't reproduce your error. happening on device or emulator? Can you give me the specs
I'm having the same (or similar) issue. I'm using an emulator on API 22.
Timeout of 5000ms has ended at 08-17 12:54:52.110.
Before the timeout, I'm drawing a circle, which goes well and is displayed. After a timeout (or interval, doesn't matter), I try to clear the canvas, but then the application crashes. Even a try / catch does nothing.
function draw(event: { canvas: Canvas })
{
const strokeWidth = 8;
const margin = 20;
const canvas = event.canvas;
const paint = new Paint();
paint.setColor(new Color('black'));
paint.setStyle(Style.STROKE);
paint.strokeWidth = strokeWidth;
const minDimension = Math.min(canvas.getWidth(), canvas.getHeight());
const radius = (minDimension - margin - strokeWidth) / 2;
canvas.drawCircle(canvas.getWidth() / 2, canvas.getHeight() / 2, radius, paint);
setTimeout(() => {
try
{
canvas!.clear();
}
catch (error)
{
console.log(error);
}
}, 5000);
}
Is it a problem with the low API version? I've had problems trying to draw RoundRect / Oval as well.
@brease-colin that s actually normal. You cant use setTimeout
in the onDraw method. The reason is that the "canvas" object is different during each call on android.
The right way to do that is to call invalidate on the canvas view in your timeout. From the resulting on draw you simply do nothing.
That works great, thanks!
Make sure to check the demo app(s) for sample usage
I checked.
Make sure to check the existing issues in this repository
I checked :+1:
If the demo apps cannot help and there is no issue for your problem, tell us about it
Hi, thank you for present good library!
I have a problem, that my app crashes when touched
Canvas
viasetTimeout()
.Please see below for my representation!
Which platform(s) does your issue occur on?
Please, provide the following version numbers that your issue occurs with:
"tns-android": { "version": "6.0.0" }
Please, tell us how to recreate the issue in as much detail as possible.
This problem ocurrs when this component's
canvas.drawRect(new Rect(0, 0, 120, 150), new Paint())
is called.In my opinion, this factor is
setTimeout()
, because below occurs nothing.Please help me x(
Thanks!