augmentmy-world / arStudio

A innovative Web editor for Augmented Reality
https://webarstudio.tripod-digital.co.nz
MIT License
54 stars 34 forks source link

Solving resizing issue with the canvas element #19

Closed kalwalt closed 4 years ago

kalwalt commented 4 years ago

This PR try to solve the issue #18 The issue can be solved adding some conditional checks to prove that the canvas element exist or not and modify the code accordingly.

kalwalt commented 4 years ago

The canvas errors seems to be fixed but i receive yet this messages in the console while trying to resize the vieport:

window.orientation undefined screen.orientation [object ScreenOrientation]

that should printed only if the arController exist, but i closed the player tab so i suppose the arController is still available, I think should instead be destroyed.

kalwalt commented 4 years ago

The fact is that inside the StopAR function we dispose the arController object:

https://github.com/augmentmy-world/arStudio/blob/a6c5a8cc69e626585a567e07ea9d60155eec87b6/editor/js/components/arcontroller.component.js#L318-L320

i think we should add another dispose later in StopAR.

kalwalt commented 4 years ago

adding a dispose at the end of StopAR as in this snippet:

if(arBackground)
        LS.GlobalScene.root.removeChild(arBackground);
    this.initVideo = true;
+ if(this.arController)
+    this.arController.dispose();
};

i get this:

arcontroller.compone…js?version=0.64:352 Uncaught TypeError: this.arController.dispose is not a function
    at ArControllerComponent.stopAR (arcontroller.compone…js?version=0.64:352)
    at Object.trigger (litegl.js?version=0.64:10617)
    at Scene.finish (litescene.js?version=0.64:14467)
    at Object.changeState (play.js?version=0.64:300)
    at Object.onPlay (play.js?version=0.64:128)
null:1 GET http://127.0.0.1:3000/editor/null 404 (Not Found)

 ​

kalwalt commented 4 years ago

Probably this happens because we use the .api and .debug version of artoolkit lib, i'm considering, at this point as said, to try instead with the minified version, probably a bit less problematic.

kalwalt commented 4 years ago

I think that the jquery issue and other error messages that i noted, i see that happens also in the master and maybe also in webglstudio.org/demo. I will report back my result soon.

kalwalt commented 4 years ago

i think that the jquery problem #21 is not due to the resize issue, but happens when the simulation/video is relaunched. I think that maybe we can try to fix also this last issue in this PR.

ThorstenBux commented 4 years ago

I've tested your branch and 'master' and found that both fail with

Uncaught (in promise) Error: Syntax error, unrecognized expression: @ENC
    at Function.se.error (jquery.min.js:2)
    at se.tokenize (jquery.min.js:2)
    at se.select (jquery.min.js:2)
    at Function.se [as find] (jquery.min.js:2)
    at k.fn.init.find (jquery.min.js:2)
    at new k.fn.init (jquery.min.js:2)
    at k (jquery.min.js:2)
    at ArControllerComponent.<anonymous> (arcontroller.component.js?version=0.64:176)
    at ARCameraParam.<anonymous> (artoolkit.min.js:1)
    at writeCallback (artoolkit.min.js:1)

the 2nd time I run the scene.

Reproduce:

  1. Create a NFT scene
  2. Play the scene and switch to player
    • Everything working fine.
  3. Stop scene
  4. Play the scene again
    • Above error shows in console and no cube is shown
ThorstenBux commented 4 years ago

If the dev tools are open when I start playing then the cube isn't placed correctly, even if I close them it is off.

I won't go down deeper here as I think you have more expertise was you were working on that quite a bit already.

kalwalt commented 4 years ago

I've tested your branch and 'master' and found that both fail with

Uncaught (in promise) Error: Syntax error, unrecognized expression: @ENC
    at Function.se.error (jquery.min.js:2)
    at se.tokenize (jquery.min.js:2)
    at se.select (jquery.min.js:2)
    at Function.se [as find] (jquery.min.js:2)
    at k.fn.init.find (jquery.min.js:2)
    at new k.fn.init (jquery.min.js:2)
    at k (jquery.min.js:2)
    at ArControllerComponent.<anonymous> (arcontroller.component.js?version=0.64:176)
    at ARCameraParam.<anonymous> (artoolkit.min.js:1)
    at writeCallback (artoolkit.min.js:1)

the 2nd time I run the scene.

Reproduce:

  1. Create a NFT scene
  2. Play the scene and switch to player
  • Everything working fine.
  1. Stop scene
  2. Play the scene again
  • Above error shows in console and no cube is shown

Yes you have well explained the problem, so you confirm that issue. is not only related to this branch.

If the dev tools are open when I start playing then the cube isn't placed correctly, even if I close them it is off.

I won't go down deeper here as I think you have more expertise was you were working on that quite a bit already.

So do you think that we can merge this? but i would try if i can solve at least partially the jquery issue. I want to test some code and eventually apply that if solve this.

ThorstenBux commented 4 years ago

I’m wondering when it was introduced? Did we introduce it or was it there before? Off for tonight

Get Outlook for iOShttps://aka.ms/o0ukef


From: Walter Perdan notifications@github.com Sent: Tuesday, February 18, 2020 11:35:06 PM To: augmentmy-world/arStudio arStudio@noreply.github.com Cc: Thorsten Bux thorsten.bux@outlook.com; Mention mention@noreply.github.com Subject: Re: [augmentmy-world/arStudio] Solving resizing issue with the canvas element (#19)

I've tested your branch and 'master' and found that both fail with

Uncaught (in promise) Error: Syntax error, unrecognized expression: @ENC at Function.se.error (jquery.min.js:2) at se.tokenize (jquery.min.js:2) at se.select (jquery.min.js:2) at Function.se [as find] (jquery.min.js:2) at k.fn.init.find (jquery.min.js:2) at new k.fn.init (jquery.min.js:2) at k (jquery.min.js:2) at ArControllerComponent. (arcontroller.component.js?version=0.64:176) at ARCameraParam. (artoolkit.min.js:1) at writeCallback (artoolkit.min.js:1)

the 2nd time I run the scene.

Reproduce:

  1. Create a NFT scene

  2. Play the scene and switch to player

    • Everything working fine.
  3. Stop scene

  4. Play the scene again

    • Above error shows in console and no cube is shown

Yes you have well explained the problem, so you confirm that issue. is not only related to this branch.

If the dev tools are open when I start playing then the cube isn't placed correctly, even if I close them it is off.

I won't go down deeper here as I think you have more expertise was you were working on that quite a bit already.

So do you think that we can merge this? but i would try if i can solve at least partially the jquery issue. I want to test some code and eventually apply that if solve this.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Faugmentmy-world%2FarStudio%2Fpull%2F19%3Femail_source%3Dnotifications%26email_token%3DAD765PAN67D7ETQ527KJ553RDO2VVA5CNFSM4KP2BMP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMBOP7A%23issuecomment-587393020&data=02%7C01%7C%7C94d7d3c2f1f04995ff1708d7b45e3977%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637176189087594673&sdata=vux786tzsXHkyRiWpPplwgf7sN%2FRSUxr1WlgV7fkEro%3D&reserved=0, or unsubscribehttps://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAD765PHQND7QFTMEJJ57XQTRDO2VVANCNFSM4KP2BMPQ&data=02%7C01%7C%7C94d7d3c2f1f04995ff1708d7b45e3977%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637176189087594673&sdata=5qQZzCZP15mdW%2FrKpOhU%2BuPzYcn1HXTie6kicbJb%2Bic%3D&reserved=0.

kalwalt commented 4 years ago

I’m wondering when it was introduced? Did we introduce it or was it there before? Off for tonight

I will try the code before applly this latest changes to see if make any difference,

kalwalt commented 4 years ago

i went back in the git history and seems that with this commit debda70ccabe2123313ad8065b5667e0f0333ad5 not happens the Jquery issue. ( but it is affected by other issue related to clientWidth). I can try to revert part of the code at that moment. and if it is ok i will push it.

kalwalt commented 4 years ago

Maybe adding this.canvas=$('canvas'); to the arcontroller.component.js wasn't a good idea, with the last commit it seems to be fixed, I will do other tests before to merge the PR.

kalwalt commented 4 years ago

The jquery issue and the resizing issue seems to be fixed. Anyway we have other issues to solve, I'm merging this so we can go ahead. Difficult to test also because the model, as already said, disappear if you close the dev console log, definetely another issue to solve.