Code Monkey home page Code Monkey logo

Comments (12)

dominic-simplan avatar dominic-simplan commented on August 23, 2024 1

Hi,

I was able to recreate the scrolling issue with a plain JS UWP app, so it is not an issue with Cordova. Seems like on a UWP app running in local mode (and only in this case and platform!) it is necessary to enable scrolling by setting the css overflow property. See also this thread for more details.

I don't know the reason for the CSP violations yet, however they don't seem to cause any issues in the app.

Thanks again for your help, I really appreciate your quick responses and suggestions!

Dominic

from cordova-windows.

janpio avatar janpio commented on August 23, 2024

Did I understand correctly that just toggling that preference disables or enables the scrolling in the app?

from cordova-windows.

dominic-simplan avatar dominic-simplan commented on August 23, 2024

@janpio yes exactly...

from cordova-windows.

dominic-simplan avatar dominic-simplan commented on August 23, 2024

And I just realized that only in local mode (where the scrolling doesn't work), the JavaScript Console in Visual Studio 2017 shows the following line when starting the app (not sure if always, but at least very often):

CSP14312: Die Direktive script-src ms-appx: 'unsafe-eval' blob: in Host Defined Policy wurde durch eine Ressource verletzt: inline script. Die Ressource wird blockiert.

Not sure if this is related or an issue though.

from cordova-windows.

janpio avatar janpio commented on August 23, 2024

It is definitely something I would investigate as it contains "ms-appx" in the error message string. Some security meta tag thing that blocks stuff?

from cordova-windows.

dominic-simplan avatar dominic-simplan commented on August 23, 2024

I tried but Visual Studio doesn't show where this CSP violation is caused and also the directive is not coming from my index.html. Seems like it is dynamically added by the runtime during startup?
So I am really clueless how to investigate this further...

from cordova-windows.

janpio avatar janpio commented on August 23, 2024

This sounds like the English version of your error message:

CSP14312: Resource violated directive 'script-src ms-appx: data: 'unsafe-eval'' in Host Defined Policy: inline script. Resource will be blocked.

(which also shows that the German version is a terrible translation, where does the "blob" come from?)

Here at least are some people having the same problem: https://forums.adobe.com/thread/2229445

Spend some time googling for the error message, I am sure you will find some instructions to add some preferences or meta tags.

from cordova-windows.

dominic-simplan avatar dominic-simplan commented on August 23, 2024

I don't think it's a translation issue, here is exactly the same error in English: https://stackoverflow.com/questions/51764412/ionic-documentviewer-in-uwp-windows-not-working?rq=1
CSP14312: Resource violated directive β€˜script-src ms-appx: 'unsafe-eval' blob:’ in Host Defined Policy: inline script. Resource will be blocked.

I already tried a lot of possible combinations of CSPs, none of which worked and the error stays the same. I rather believe the UWP runtime adds this CSP rule dynamically when executing the app in local mode and this again causes issues when using Cordova-based frameworks or the WebView in general.

According to this comment, inline scripts are not allowed when running the windows app in local mode.
Unfortunately I need local mode as I need local network access.

As it seems that Microsoft doesn't allow inline scripts for the script-src, the question might be: Where is Cordova (or the Example App?) using inline scripting, is it necessary and would it solve the scrolling issue...?

from cordova-windows.

janpio avatar janpio commented on August 23, 2024

I don't think it's a translation issue, here is exactly the same error in English

Good catch, I didn't find this.

For all the rest: Sorry, no idea :/

from cordova-windows.

dominic-simplan avatar dominic-simplan commented on August 23, 2024

Okay I just tried to added the directive script-src ms-appx-web: 'unsafe-eval' blob: to my index.html and switch the app to remote mode: I can also see the violation, but scrolling works fine.
So the scrolling issue doesn't seem to be related to the CSP violation (which possibly doesn't have any bad side effects).

To wrap it up:

  • A CSP violation error due to inline script is displayed when running the UWP app in local mode as the runtime dynamically overwrites the script-src policy at runtime. It is unknown what's blocked exactly, but most likely unrelated to the scrolling issue
  • Scrolling does not work when local mode is enabled.

Do you think I should check directly with Microsoft or the Cordova Core team? I have no clue how to continue analyzing this issue. We just recently migrated to Cordova. Before we were using Xamarin with a WebView for the same app and scrolling was working...

from cordova-windows.

janpio avatar janpio commented on August 23, 2024

If you have contact at Microsoft, go for it - they should know a bit about it.

I am one of the random (and volunteer) people that make up the Cordova Core team - there are currently not too many people around that know much about cordova-windows. You might try mailnig the dev list or ask in the correct channel in Slack: https://cordova.apache.org/contact/

from cordova-windows.

janpio avatar janpio commented on August 23, 2024

Wow, that is a pretty surprising outcome. Glad you found out!

We should probably add this to the documentation then. Could you summarize the situation in one or two sentences and add it here somehow: https://github.com/apache/cordova-docs/blob/master/www/docs/en/dev/guide/platforms/windows/index.md#understanding-remote-mode-vs-local-mode (I think that is the best what we currently have in docs)

from cordova-windows.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.